-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Move toObject, toArray API to separate plugin from core
- Loading branch information
Showing
6 changed files
with
60 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default (o, c) => { | ||
const proto = c.prototype | ||
proto.toArray = function () { | ||
return [ | ||
this.$y, | ||
this.$M, | ||
this.$D, | ||
this.$H, | ||
this.$m, | ||
this.$s, | ||
this.$ms | ||
] | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default (o, c) => { | ||
const proto = c.prototype | ||
proto.toObject = function () { | ||
return { | ||
years: this.$y, | ||
months: this.$M, | ||
date: this.$D, | ||
hours: this.$H, | ||
minutes: this.$m, | ||
seconds: this.$s, | ||
milliseconds: this.$ms | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
toArray(): number[] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
interface DayjsObject { | ||
years: number | ||
months: number | ||
date: number | ||
hours: number | ||
minutes: number | ||
seconds: number | ||
milliseconds: number | ||
} | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
toObject(): DayjsObject | ||
} | ||
} |