Skip to main content

API Reference

Classes ​

Datetime ​

Represents a local or UTC date object.

Methods ​

NameDescription
toIso
Returns ISO-8601 string.
toUtc
Returns a Datetime represents the same date in utc.

toIso ​
toIso(): str

Returns ISO-8601 string.

toUtc ​
toUtc(): datetime

Returns a Datetime represents the same date in utc.

Static Functions ​

NameDescription
fromComponents
Create a Datetime from Datetime components.
fromDate
Create a Datetime from a JavaScript Date object.
fromIso
Create a Datetime from an ISO-8601 string.
systemNow
Create a Datetime from local system timezone.
utcNow
Create a Datetime from UTC timezone.

fromComponents ​
datetime.fromComponents(c: DatetimeComponents);

Create a Datetime from Datetime components.

cRequired ​

DatetimeComponents.


fromDate ​
datetime.fromDate(date: datetime);

Create a Datetime from a JavaScript Date object.

dateRequired ​
  • Type: datetime

The JavaScript Date object.


fromIso ​
datetime.fromIso(iso: str);

Create a Datetime from an ISO-8601 string.

isoRequired ​
  • Type: str

ISO-8601 string.


systemNow ​
datetime.systemNow();

Create a Datetime from local system timezone.

utcNow ​
datetime.utcNow();

Create a Datetime from UTC timezone.

Properties ​

NameTypeDescription
dayOfMonth
numReturns the day of month in the local machine time or in utc (1 - 31).
dayOfWeek
numReturns the day in month of the local machine time or in utc (0 - 6).
hours
numReturns the hour of the local machine time or in utc.
min
numReturns the minute of the local machine time or in utc.
month
numReturns the month of the local machine time or in utc (0 - 11).
ms
numReturns the milliseconds of the local machine time or in utc *.
sec
numReturns the seconds of the local machine time or in utc.
timestamp
numReturn a timestamp of non-leap year seconds since epoch.
timestampMs
numReturn a timestamp of non-leap year milliseconds since epoch.
timezone
numReturns the offset in minutes from UTC.
year
numReturns the year of the local machine time or in utc.

dayOfMonthRequired ​
dayOfMonth: num;
  • Type: num

Returns the day of month in the local machine time or in utc (1 - 31).


dayOfWeekRequired ​
dayOfWeek: num;
  • Type: num

Returns the day in month of the local machine time or in utc (0 - 6).


hoursRequired ​
hours: num;
  • Type: num

Returns the hour of the local machine time or in utc.


minRequired ​
min: num;
  • Type: num

Returns the minute of the local machine time or in utc.


monthRequired ​
month: num;
  • Type: num

Returns the month of the local machine time or in utc (0 - 11).


msRequired ​
ms: num;
  • Type: num

Returns the milliseconds of the local machine time or in utc *.


secRequired ​
sec: num;
  • Type: num

Returns the seconds of the local machine time or in utc.


timestampRequired ​
timestamp: num;
  • Type: num

Return a timestamp of non-leap year seconds since epoch.


timestampMsRequired ​
timestampMs: num;
  • Type: num

Return a timestamp of non-leap year milliseconds since epoch.


timezoneRequired ​
timezone: num;
  • Type: num

Returns the offset in minutes from UTC.


yearRequired ​
year: num;
  • Type: num

Returns the year of the local machine time or in utc.


Structs ​

DatetimeComponents ​

Interface that is used for setting Datetime date.

Initializer ​

let DatetimeComponents = DatetimeComponents{ ... };

Properties ​

NameTypeDescription
day
numDay.
hour
numHours.
min
numMinutes.
month
numMonth.
ms
numMilliseconds.
sec
numSeconds.
tz
numTimezone offset in minutes from UTC.
year
numYear.

dayRequired ​
day: num;
  • Type: num

Day.


hourRequired ​
hour: num;
  • Type: num

Hours.


minRequired ​
min: num;
  • Type: num

Minutes.


monthRequired ​
month: num;
  • Type: num

Month.


msRequired ​
ms: num;
  • Type: num

Milliseconds.


secRequired ​
sec: num;
  • Type: num

Seconds.


tzRequired ​
tz: num;
  • Type: num

Timezone offset in minutes from UTC.


yearRequired ​
year: num;
  • Type: num

Year.