Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add index.d.ts #37

Merged
merged 2 commits into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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