Skip to content

PosixDate

[Source]

Represents a proleptic Gregorian date and time, without specifying a time zone. The day of month and month are indexed from 1 (January is 1). day_of_week follows C's tm_wday convention (0=Sunday through 6=Saturday). day_of_year follows C's tm_yday convention (0-based, January 1 is 0).

The representable range starts at 1970-01-01 00:00:00. The upper bound depends on the platform's gmtime implementation: year 3000 on Windows, year 2147483647 elsewhere. Arguments that fall outside this range are clamped: negative values are treated as zero, and values beyond the maximum representable date are treated as the maximum.

class ref PosixDate

Constructors

create

[Source]

Create a date from a POSIX time. Negative arguments are clamped to zero. Combined values beyond year 2147483647 are clamped to the maximum representable date.

new ref create(
  seconds: I64 val = 0,
  nanoseconds: I64 val = 0)
: PosixDate ref^

Parameters

  • seconds: I64 val = 0
  • nanoseconds: I64 val = 0

Returns


Public fields

var nsec: I32 val

[Source]


var sec: I32 val

[Source]


var min: I32 val

[Source]


var hour: I32 val

[Source]


var day_of_month: I32 val

[Source]


var month: I32 val

[Source]


var year: I32 val

[Source]


var day_of_week: I32 val

[Source]


var day_of_year: I32 val

[Source]


Public Functions

time

[Source]

Return a POSIX time. Treats the date as UTC.

fun box time()
: I64 val

Returns


normal

[Source]

Normalise all the fields of the date. For example, if the hour is 24, it is set to 0 and the day is advanced. This allows fields to be changed naively, eg. adding 1000 to hours to advance the time by 1000 hours, and then normalising the date.

fun ref normal()
: None val

Returns


format

[Source]

Format the time as for strftime.

fun box format(
  fmt: String val)
: String val ?

Parameters

Returns