forked from iamkun/dayjs
-
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.
Merge pull request iamkun#37 from varHarrie/master
Add index.d.ts
- Loading branch information
Showing
3 changed files
with
155 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import dayjs from '.' | ||
|
||
dayjs() | ||
|
||
dayjs('1993-03-1') | ||
|
||
dayjs(730944000000) | ||
|
||
dayjs(new Date(1993, 3, 1)) | ||
|
||
dayjs().clone() | ||
|
||
dayjs().isValid() | ||
|
||
dayjs().year() | ||
|
||
dayjs().month() | ||
|
||
dayjs().date() | ||
|
||
dayjs().hour() | ||
|
||
dayjs().minute() | ||
|
||
dayjs().second() | ||
|
||
dayjs().millisecond() | ||
|
||
dayjs().set('month', 3) | ||
dayjs().set('second', 30) | ||
|
||
dayjs().add(7, 'day') | ||
|
||
dayjs().subtract(7, 'year') | ||
|
||
dayjs().startOf('year') | ||
|
||
dayjs().endOf('month') | ||
|
||
dayjs().startOf('month').add(1, 'day').subtract(1, 'year') | ||
|
||
dayjs().format() | ||
dayjs().format('[YYYY] MM-DDTHH:mm:ssZ') | ||
|
||
dayjs().diff(dayjs(), 'year') | ||
|
||
dayjs().valueOf() | ||
|
||
dayjs().unix() | ||
|
||
dayjs().daysInMonth() | ||
|
||
dayjs().toDate() | ||
|
||
dayjs().toArray() | ||
|
||
dayjs().toJSON() | ||
|
||
dayjs().toISOString() | ||
|
||
dayjs().toObject() | ||
|
||
dayjs().toString() | ||
|
||
dayjs().isBefore(dayjs()) | ||
|
||
dayjs().isSame(dayjs()) | ||
|
||
dayjs().isAfter(dayjs()) | ||
|
||
dayjs('2000-01-01').isLeapYear(dayjs()) |
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,83 @@ | ||
// Type definitions for dayjs 1.0 | ||
// Project: https://github.com/xx45/dayjs | ||
// Definitions by: varHarrie <https://github.com/varHarrie> | ||
|
||
type ConfigType = string | number | Date | Dayjs | ||
|
||
type UnitType = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'date' | ||
|
||
interface DayjsObject { | ||
years: number | ||
months: number | ||
date: number | ||
hours: number | ||
minutes: number | ||
seconds: number | ||
milliseconds: number | ||
} | ||
|
||
declare class Dayjs { | ||
constructor (config?: ConfigType) | ||
|
||
clone(): Dayjs | ||
|
||
isValid(): boolean | ||
|
||
year(): number | ||
|
||
month(): number | ||
|
||
date(): number | ||
|
||
hour(): number | ||
|
||
minute(): number | ||
|
||
second(): number | ||
|
||
millisecond(): number | ||
|
||
set(unit: UnitType, value: number): Dayjs | ||
|
||
add(value: number, unit: UnitType): Dayjs | ||
|
||
subtract(value: number, unit: UnitType): Dayjs | ||
|
||
startOf(unit: UnitType): Dayjs | ||
|
||
endOf(unit: UnitType): Dayjs | ||
|
||
format(template?: string): string | ||
|
||
diff(dayjs: Dayjs, unit: UnitType, float?: boolean): number | ||
|
||
valueOf(): number | ||
|
||
unix(): number | ||
|
||
daysInMonth(): number | ||
|
||
toDate(): Date | ||
|
||
toArray(): number[] | ||
|
||
toJSON(): string | ||
|
||
toISOString(): string | ||
|
||
toObject(): Object | ||
|
||
toString(): string | ||
|
||
isBefore(dayjs: Dayjs): boolean | ||
|
||
isSame(dayjs: Dayjs) | ||
|
||
isAfter(dayjs: Dayjs) | ||
|
||
isLeapYear(dayjs?: Dayjs): boolean | ||
} | ||
|
||
declare function dayjs (config?: ConfigType): Dayjs | ||
|
||
export default dayjs |
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