Railgun

if it ain't broke, we'll break it

User Tools

Site Tools


senses:packages:kmj-datetime

kmj-datetime

The kmj-datetime package provides additional date/time handling functions to account for shortcomings with the date/time functions that are a part of the Lua io package.

The runtime provides this library through the luaL_newlib auxiliary library function, so all fields can be assumed to be functions.

now

The now field contains a function that returns the current time represented as a number with the milliseconds since January 1st, 1970 at 12:00 AM UTC.

Syntax

now(): (timestamp: number)

Arguments

This function takes no arguments.

Returns

  1. The first return value contains the current time in milliseconds since January 1st, 1970 at 12:00 AM UTC.

fromISO8601

This field contains a function that takes an ISO8601 formatted date/time string and converts it to milliseconds since January 1st, 1970 at 12:00 AM UTC.

Syntax

fromISO8601(iso8601str: string): (timestamp: number|nil)

Arguments

  1. The first argument should contain the ISO8601 string representation of the timestamp.

Returns

  1. The first return value will contain the amount of milliseconds since January 1st, 1970 at 12:00 AM UTC that the timestamp represents, or nil if the string could not be understood.

toISO8601

Converts a number containing milliseconds since January 1st, 1970 at 12:00 AM UTC to a ISO8601 Zulu string representation.

Syntax

toISO8601(timestamp: number): (iso8601str: string)

Arguments

  1. The first argument should contain the amount of milliseconds since January 1st, 1970 at 12:00 AM UTC that must be converted to a ISO8601 string.

Returns

  1. The first return value will be an ISO8601 Zulu string representing the given numeric timestamp.
senses/packages/kmj-datetime.txt · Last modified: by flash