-
-
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: Add plugin type definitions (#418)
- Loading branch information
Showing
27 changed files
with
221 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ coverage | |
/plugin | ||
dayjs.min.js | ||
/esm | ||
index.d.ts | ||
|
||
#dev | ||
demo.js |
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
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
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,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as dayOfYear from 'dayjs/plugin/dayOfYear' | ||
|
||
dayjs.extend(dayOfYear) | ||
|
||
dayjs('2015-01-01T00:00:00.000').dayOfYear() === 1 |
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,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as isBetween from 'dayjs/plugin/isBetween' | ||
|
||
dayjs.extend(isBetween) | ||
|
||
dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25')) === true |
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,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as isLeapYear from 'dayjs/plugin/isLeapYear' | ||
|
||
dayjs.extend(isLeapYear) | ||
|
||
dayjs('2010-10-20').isLeapYear() === false |
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,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as isSameOrAfter from 'dayjs/plugin/isSameOrAfter' | ||
|
||
dayjs.extend(isSameOrAfter) | ||
|
||
dayjs('2010-10-20').isSameOrAfter('2010-10-19', 'year') === true |
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,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as isSameOrBefore from 'dayjs/plugin/isSameOrBefore' | ||
|
||
dayjs.extend(isSameOrBefore) | ||
|
||
dayjs('2010-10-20').isSameOrBefore('2010-10-19', 'year') === true |
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,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as quarterOfYear from 'dayjs/plugin/quarterOfYear' | ||
|
||
dayjs.extend(quarterOfYear) | ||
|
||
dayjs('2013-01-01T00:00:00.000').quarter() === 1 |
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 * as dayjs from 'dayjs' | ||
import * as relativeTime from 'dayjs/plugin/relativeTime' | ||
|
||
dayjs.extend(relativeTime) | ||
|
||
dayjs().fromNow().trim() | ||
dayjs().fromNow(true).trim() | ||
|
||
dayjs().from(dayjs()).trim() | ||
dayjs().from(123, true).trim() | ||
dayjs().from('2018-01-23').trim() | ||
dayjs().from(new Date(), true).trim() | ||
|
||
dayjs().toNow().trim() | ||
dayjs().toNow(true).trim() | ||
|
||
dayjs().to(dayjs()).trim() | ||
dayjs().to(123, true).trim() | ||
dayjs().to('2018-01-23').trim() | ||
dayjs().to(new Date(), true).trim() |
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,6 @@ | ||
import * as dayjs from 'dayjs' | ||
import * as weekOfYear from 'dayjs/plugin/weekOfYear' | ||
|
||
dayjs.extend(weekOfYear) | ||
|
||
dayjs('2010-10-20').week() === 43 |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"noEmit": true, | ||
"lib": [ | ||
// TODO: Unfortunately, rollup brings @types/node and etc. with "dependencies", not "devDependencies". | ||
// It references Symbol type. | ||
"es5", | ||
"es2015.symbol" | ||
], | ||
"baseUrl": "./types", | ||
"paths": { | ||
"dayjs": [ "." ], | ||
"dayjs/*": [ "*" ] | ||
} | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
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,4 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin |
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,4 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin |
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,4 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin |
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 { | ||
dayOfYear(): 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,10 @@ | ||
import { PluginFunc, DateType } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
isBetween(a: DateType, b: DateType): boolean | ||
} | ||
} |
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 { | ||
isLeapYear(): boolean | ||
} | ||
} |
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 { | ||
isSameOrAfter(date: DateType, unit?: OpUnitType): boolean | ||
} | ||
} |
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 { | ||
isSameOrBefore(date: DateType, unit?: OpUnitType): boolean | ||
} | ||
} |
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,4 @@ | ||
import { PluginFunc } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin |
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 { | ||
quarter(): 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,13 @@ | ||
import { PluginFunc, DateType } from 'dayjs' | ||
|
||
declare const plugin: PluginFunc | ||
export = plugin | ||
|
||
declare module 'dayjs' { | ||
interface Dayjs { | ||
fromNow(withoutSuffix?: boolean): string | ||
from(compared: DateType, withoutSuffix?: boolean): string | ||
toNow(withoutSuffix?: boolean): string | ||
to(compared: DateType, withoutSuffix?: boolean): string | ||
} | ||
} |
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 { | ||
week(): number | ||
} | ||
} |