@univerjscorefunctionsclassesDayjs

@univerjs/core v0.5.0-beta.1 • Docs


Class: Dayjs

Constructors

new Dayjs()

new Dayjs(config?): Dayjs

Parameters

ParameterType
config?| null | string | number | Date | Dayjs

Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:34

Methods

add()

add(value, unit?): Dayjs

Returns a cloned Day.js object with a specified amount of time added.

dayjs().add(7, 'day')// => Dayjs

Units are case insensitive, and support plural and short forms.

Docs: https://day.js.org/docs/en/manipulate/add

Parameters

ParameterType
valuenumber
unit?ManipulateType

Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:240


clone()

clone(): Dayjs

All Day.js objects are immutable. Still, dayjs#clone can create a clone of the current object if you need one.

dayjs().clone()// => Dayjs
dayjs(dayjs('2019-01-25')) // passing a Dayjs object to a constructor will also clone it

Docs: https://day.js.org/docs/en/parse/dayjs-clone

Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:43


date()

date(undefined)

date(): number

Get the date of the month.

dayjs().date()// => 1-31

Docs: https://day.js.org/docs/en/get-set/date

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:97

date(value)

date(value): Dayjs

Set the date of the month.

Accepts numbers from 1 to 31. If the range is exceeded, it will bubble up to the next months.

dayjs().date(1)// => Dayjs

Docs: https://day.js.org/docs/en/get-set/date

Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:107


day()

day(undefined)

day(): 
  | 0
  | 1
  | 2
  | 3
  | 4
  | 5
  | 6

Get the day of the week.

Returns numbers from 0 (Sunday) to 6 (Saturday).

dayjs().day()// 0-6

Docs: https://day.js.org/docs/en/get-set/day

Returns

| 0 | 1 | 2 | 3 | 4 | 5 | 6

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:117

day(value)

day(value): Dayjs

Set the day of the week.

Accepts numbers from 0 (Sunday) to 6 (Saturday). If the range is exceeded, it will bubble up to next weeks.

dayjs().day(0)// => Dayjs

Docs: https://day.js.org/docs/en/get-set/day

Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:127


daysInMonth()

daysInMonth(): number

Get the number of days in the current month.

dayjs('2019-01-25').daysInMonth() // 31

Docs: https://day.js.org/docs/en/display/days-in-month

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:332


diff()

diff(
   date?, 
   unit?, 
   float?): number

This indicates the difference between two date-time in the specified unit.

To get the difference in milliseconds, use dayjs#diff

const date1 = dayjs('2019-01-25')
const date2 = dayjs('2018-06-05')
date1.diff(date2) // 20214000000 default milliseconds
date1.diff() // milliseconds to current time

To get the difference in another unit of measurement, pass that measurement as the second argument.

const date1 = dayjs('2019-01-25')
date1.diff('2018-06-05', 'month') // 7

Units are case insensitive, and support plural and short forms.

Docs: https://day.js.org/docs/en/display/difference

Parameters

ParameterType
date?| null | string | number | Date | Dayjs
unit?| "d" | "s" | "ms" | "D" | "M" | "Q" | "w" | "h" | "date" | "y" | "millisecond" | "second" | "minute" | "hour" | "day" | "month" | "year" | "milliseconds" | "seconds" | "minutes" | "hours" | "days" | "months" | "years" | "dates" | "m" | "week" | "weeks" | "quarter" | "quarters"
float?boolean

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:303


endOf()

endOf(unit): Dayjs

Returns a cloned Day.js object and set it to the end of a unit of time.

dayjs().endOf('month')// => Dayjs

Units are case insensitive, and support plural and short forms.

Docs: https://day.js.org/docs/en/manipulate/end-of

Parameters

ParameterType
unitOpUnitType

Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:270


format()

format(template?): string

Get the formatted date according to the string of tokens passed in.

To escape characters, wrap them in square brackets (e.g. [MM]).

dayjs().format()// => current date in ISO8601, without fraction seconds e.g. '2020-04-02T08:02:17-05:00'
dayjs('2019-01-25').format('[YYYYescape] YYYY-MM-DDTHH:mm:ssZ[Z]')// 'YYYYescape 2019-01-25T00:00:00-02:00Z'
dayjs('2019-01-25').format('DD/MM/YYYY') // '25/01/2019'

Docs: https://day.js.org/docs/en/display/format

Parameters

ParameterType
template?string

Returns

string

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:282


get()

get(unit): number

String getter, returns the corresponding information getting from Day.js object.

In general:

dayjs().get(unit) === dayjs()[unit]()

Units are case insensitive, and support plural and short forms.

dayjs().get('year')
dayjs().get('month') // start 0
dayjs().get('date')

Docs: https://day.js.org/docs/en/get-set/get

Parameters

ParameterType
unitUnitType

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:230


hour()

hour(undefined)

hour(): number

Get the hour.

dayjs().hour()// => 0-23

Docs: https://day.js.org/docs/en/get-set/hour

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:135

hour(value)

hour(value): Dayjs

Set the hour.

Accepts numbers from 0 to 23. If the range is exceeded, it will bubble up to the next day.

dayjs().hour(12)// => Dayjs

Docs: https://day.js.org/docs/en/get-set/hour

Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:145


isAfter()

isAfter(date?, unit?): boolean

This indicates whether the Day.js object is after the other supplied date-time.

dayjs().isAfter(dayjs('2011-01-01')) // default milliseconds

If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.

dayjs().isAfter('2011-01-01', 'year')// => boolean

Units are case insensitive, and support plural and short forms.

Docs: https://day.js.org/docs/en/query/is-after

Parameters

ParameterType
date?| null | string | number | Date | Dayjs
unit?OpUnitType

Returns

boolean

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:411


isBefore()

isBefore(date?, unit?): boolean

This indicates whether the Day.js object is before the other supplied date-time.

dayjs().isBefore(dayjs('2011-01-01')) // default milliseconds

If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.

dayjs().isBefore('2011-01-01', 'year')// => boolean

Units are case insensitive, and support plural and short forms.

Docs: https://day.js.org/docs/en/query/is-before

Parameters

ParameterType
date?| null | string | number | Date | Dayjs
unit?OpUnitType

Returns

boolean

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:385


isSame()

isSame(date?, unit?): boolean

This indicates whether the Day.js object is the same as the other supplied date-time.

dayjs().isSame(dayjs('2011-01-01')) // default milliseconds

If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.

dayjs().isSame('2011-01-01', 'year')// => boolean

Docs: https://day.js.org/docs/en/query/is-same

Parameters

ParameterType
date?| null | string | number | Date | Dayjs
unit?OpUnitType

Returns

boolean

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:397


isUTC()

isUTC(): boolean

Returns

boolean

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.d.ts:13


isValid()

isValid(): boolean

This returns a boolean indicating whether the Day.js object contains a valid date or not.

dayjs().isValid()// => boolean

Docs: https://day.js.org/docs/en/parse/is-valid

Returns

boolean

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:51


local()

local(): Dayjs

Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.d.ts:11


locale()

locale(undefined)

locale(): string
Returns

string

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:413

locale(preset, object)

locale(preset, object?): Dayjs
Parameters
ParameterType
presetstring | ILocale
object?Partial<ILocale>
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:415


localeData()

localeData(): InstanceLocaleDataReturn

Returns

InstanceLocaleDataReturn

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/localeData.d.ts:35


millisecond()

millisecond(undefined)

millisecond(): number

Get the milliseconds.

dayjs().millisecond()// => 0-999

Docs: https://day.js.org/docs/en/get-set/millisecond

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:188

millisecond(value)

millisecond(value): Dayjs

Set the milliseconds.

Accepts numbers from 0 to 999. If the range is exceeded, it will bubble up to the next seconds.

dayjs().millisecond(1)// => Dayjs

Docs: https://day.js.org/docs/en/get-set/millisecond

Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:198


minute()

minute(undefined)

minute(): number

Get the minutes.

dayjs().minute()// => 0-59

Docs: https://day.js.org/docs/en/get-set/minute

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:153

minute(value)

minute(value): Dayjs

Set the minutes.

Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the next hour.

dayjs().minute(59)// => Dayjs

Docs: https://day.js.org/docs/en/get-set/minute

Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:163


month()

month(undefined)

month(): number

Get the month.

Months are zero indexed, so January is month 0.

dayjs().month()// => 0-11

Docs: https://day.js.org/docs/en/get-set/month

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:77

month(value)

month(value): Dayjs

Set the month.

Months are zero indexed, so January is month 0.

Accepts numbers from 0 to 11. If the range is exceeded, it will bubble up to the next year.

dayjs().month(0)// => Dayjs

Docs: https://day.js.org/docs/en/get-set/month

Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:89


second()

second(undefined)

second(): number

Get the seconds.

dayjs().second()// => 0-59

Docs: https://day.js.org/docs/en/get-set/second

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:171

second(value)

second(value): Dayjs

Set the seconds.

Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the next minutes.

dayjs().second(1)// Dayjs
Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:180


set()

set(unit, value): Dayjs

Generic setter, accepting unit as first argument, and value as second, returns a new instance with the applied changes.

In general:

dayjs().set(unit, value) === dayjs()[unit](value)

Units are case insensitive, and support plural and short forms.

dayjs().set('date', 1)
dayjs().set('month', 3) // April
dayjs().set('second', 30)

Docs: https://day.js.org/docs/en/get-set/set

Parameters

ParameterType
unitUnitType
valuenumber

Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:214


startOf()

startOf(unit): Dayjs

Returns a cloned Day.js object and set it to the start of a unit of time.

dayjs().startOf('year')// => Dayjs

Units are case insensitive, and support plural and short forms.

Docs: https://day.js.org/docs/en/manipulate/start-of

Parameters

ParameterType
unitOpUnitType

Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:260


subtract()

subtract(value, unit?): Dayjs

Returns a cloned Day.js object with a specified amount of time subtracted.

dayjs().subtract(7, 'year')// => Dayjs

Units are case insensitive, and support plural and short forms.

Docs: https://day.js.org/docs/en/manipulate/subtract

Parameters

ParameterType
valuenumber
unit?ManipulateType

Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:250


toDate()

toDate(): Date

To get a copy of the native Date object parsed from the Day.js object use dayjs#toDate.

dayjs('2019-01-25').toDate()// => Date

Returns

Date

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:339


toISOString()

toISOString(): string

To format as an ISO 8601 string.

dayjs('2019-01-25').toISOString() // '2019-01-25T02:00:00.000Z'

Docs: https://day.js.org/docs/en/display/as-iso-string

Returns

string

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:355


toJSON()

toJSON(): string

To serialize as an ISO 8601 string.

dayjs('2019-01-25').toJSON() // '2019-01-25T02:00:00.000Z'

Docs: https://day.js.org/docs/en/display/as-json

Returns

string

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:347


toString()

toString(): string

Returns a string representation of the date.

dayjs('2019-01-25').toString() // 'Fri, 25 Jan 2019 02:00:00 GMT'

Docs: https://day.js.org/docs/en/display/as-string

Returns

string

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:363


unix()

unix(): number

This returns the Unix timestamp (the number of seconds since the Unix Epoch) of the Day.js object.

dayjs('2019-01-25').unix() // 1548381600

This value is floored to the nearest second, and does not include a milliseconds component.

Docs: https://day.js.org/docs/en/display/unix-timestamp

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:324


utc()

utc(keepLocalTime?): Dayjs

Parameters

ParameterType
keepLocalTime?boolean

Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.d.ts:9


utcOffset()

utcOffset(undefined)

utcOffset(): number

Get the UTC offset in minutes.

dayjs().utcOffset()

Docs: https://day.js.org/docs/en/manipulate/utc-offset

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:371

utcOffset(offset, keepLocalTime)

utcOffset(offset, keepLocalTime?): Dayjs
Parameters
ParameterType
offsetstring | number
keepLocalTime?boolean
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/utc.d.ts:15


valueOf()

valueOf(): number

This returns the number of milliseconds since the Unix Epoch of the Day.js object.

dayjs('2019-01-25').valueOf() // 1548381600000
+dayjs(1548381600000) // 1548381600000

To get a Unix timestamp (the number of seconds since the epoch) from a Day.js object, you should use Unix Timestamp dayjs#unix().

Docs: https://day.js.org/docs/en/display/unix-timestamp-milliseconds

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:314


week()

week(undefined)

week(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/weekOfYear.d.ts:8

week(value)

week(value): Dayjs
Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/weekOfYear.d.ts:10


weekday()

weekday(undefined)

weekday(): number
Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/weekday.d.ts:8

weekday(value)

weekday(value): Dayjs
Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/weekday.d.ts:10


weekYear()

weekYear(): number

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/plugin/weekYear.d.ts:8


year()

year(undefined)

year(): number

Get the year.

dayjs().year()// => 2020

Docs: https://day.js.org/docs/en/get-set/year

Returns

number

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:59

year(value)

year(value): Dayjs

Set the year.

dayjs().year(2000)// => Dayjs

Docs: https://day.js.org/docs/en/get-set/year

Parameters
ParameterType
valuenumber
Returns

Dayjs

Defined in

packages/api/tmp/univer-pro/node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/index.d.ts:67