Skip to content

Commit

Permalink
Merge pull request iamkun#37 from varHarrie/master
Browse files Browse the repository at this point in the history
Add index.d.ts
  • Loading branch information
iamkun authored May 7, 2018
2 parents 7f7f56a + 7436bf4 commit d9a2680
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 0 deletions.
71 changes: 71 additions & 0 deletions index.d.test.ts
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())
83 changes: 83 additions & 0 deletions index.d.ts
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0-development",
"description": "",
"main": "dist/dayjs.min.js",
"types": "index.d.ts",
"scripts": {
"test": "jest",
"lint": "./node_modules/.bin/eslint src/* test/*",
Expand Down

0 comments on commit d9a2680

Please sign in to comment.