time - clocks and pauses.
Durations are milliseconds, whole numbers. Wall clock time is what a clock on the wall says and can jump backwards, the monotonic one only moves forward and is the one to measure with.
¶Millisecond = 1valuesource
¶Second = 1000valuesource
¶Minute = 60000valuesource
¶Hour = 3600000valuesource
¶Now = fn()source
Now returns the wall clock time in milliseconds since the Unix epoch.
¶Unix = fn()source
Unix returns the wall clock time in whole seconds since the Unix epoch.
¶Mono = fn()source
Mono returns a monotonic timestamp in milliseconds. Only differences between two of these have a meaning.
¶Since = fn(t)source
Since returns the milliseconds elapsed since the monotonic timestamp t.
¶Sleep = fn(ms)source
Sleep pauses the current tau routine for ms milliseconds.
¶Measure = fn(f)source
Measure returns the milliseconds taken by f().
¶Daysvaluesource
¶Monthsvaluesource
¶Date = fn(sec)source
Date returns what the wall clock time sec, in seconds since the Unix epoch, stands for: Year, Month (1 to 12), Day, Hour, Minute, Second, the Weekday with Sunday as 0, and the YearDay starting at 1.
The calendar arithmetic is the one Howard Hinnant wrote for chrono: days are counted from the first of March so that the leap day falls at the end of the year, where it does no harm.
¶Unix = secvaluesource
¶Offset = offsetvaluesource
¶Year = yvaluesource
¶Month = mvaluesource
¶Day = dvaluesource
¶Hour = div(rem, 3600)valuesource
¶Minute = mod(div(rem, 60), 60)valuesource
¶Second = mod(rem, 60)valuesource
¶Weekday = mod(days + 4, 7)valuesource
¶YearDay = days - daysFromCivil(y, 1, 1) + 1valuesource
¶DateIn = fn(sec, offset)source
DateIn is Date with a zone: offset is the seconds between that zone and UTC, 3600 for Rome in winter and 7200 in summer. The fields read as the clock on that wall reads, while Unix stays the instant it is.
¶Unix = secvaluesource
¶Offset = offsetvaluesource
¶Year = yvaluesource
¶Month = mvaluesource
¶Day = dvaluesource
¶Hour = div(rem, 3600)valuesource
¶Minute = mod(div(rem, 60), 60)valuesource
¶Second = mod(rem, 60)valuesource
¶Weekday = mod(days + 4, 7)valuesource
¶YearDay = days - daysFromCivil(y, 1, 1) + 1valuesource
¶LocalOffset = fn(sec)source
LocalOffset is the offset of the local zone at the instant sec, or right now when sec is null.
¶LocalZone = fn(sec)source
LocalZone is the abbreviation of the local zone at that instant: CET, CEST.
¶Local = fn(sec)source
Local returns the date sec stands for where this machine is.
¶Unix = secvaluesource
¶Offset = offsetvaluesource
¶Year = yvaluesource
¶Month = mvaluesource
¶Day = dvaluesource
¶Hour = div(rem, 3600)valuesource
¶Minute = mod(div(rem, 60), 60)valuesource
¶Second = mod(rem, 60)valuesource
¶Weekday = mod(days + 4, 7)valuesource
¶YearDay = days - daysFromCivil(y, 1, 1) + 1valuesource
¶NowLocal = fn()source
Now returns the local date of this instant.
¶Unix = secvaluesource
¶Offset = offsetvaluesource
¶Year = yvaluesource
¶Month = mvaluesource
¶Day = dvaluesource
¶Hour = div(rem, 3600)valuesource
¶Minute = mod(div(rem, 60), 60)valuesource
¶Second = mod(rem, 60)valuesource
¶Weekday = mod(days + 4, 7)valuesource
¶YearDay = days - daysFromCivil(y, 1, 1) + 1valuesource
¶FromDate = fn(year, month, day, hour, minute, second)source
FromDate returns the seconds since the epoch of the given UTC date, the way back from Date.
¶FromDateIn = fn(year, month, day, hour, minute, second, offset)source
FromDateIn is FromDate in a zone: the date is read as the clock of that zone reads it, and the instant comes back in UTC.
¶Sunday = 0valuesource
¶Monday = 1valuesource
¶Tuesday = 2valuesource
¶Wednesday = 3valuesource
¶Thursday = 4valuesource
¶Friday = 5valuesource
¶Saturday = 6valuesource
¶ISOWeekday = fn(t)source
ISOWeekday numbers the days from Monday as 1 to Sunday as 7.
¶IsWeekend = fn(t)source
IsWeekend reports whether the date falls on a Saturday or a Sunday.
¶StartOfDay = fn(t)source
StartOfDay returns the instant the day of t begins, in its own zone.
¶StartOfWeek = fn(t, first)source
StartOfWeek returns the instant the week holding t begins, with first saying which day that is: Monday in most of Europe, Sunday elsewhere. With no first, Monday.
¶Week = fn(t, first)source
Week returns the number of the week holding t, counting from the first week that starts on a first day, with the days before it in week 0. It is what a calendar on a wall shows.
¶ISOWeek = fn(t)source
ISOWeek returns the ISO 8601 year and week of t: weeks start on Monday and week 1 is the one holding the 4th of January, so the first days of January can belong to the last week of the year before.
¶IsLeap = fn(y)source
IsLeap reports whether the year has a 29th of February.
¶Format = fn(t, layout)source
Format writes t, a date from Date, in the given layout. The verbs are the ones of strftime, the handful that are worth having:
%Y year %m month %d day %j day of the year
%H hour %M minute %S second
%b month name, short %B month name
%a day name, short %A day name
%z offset from UTC %% a per cent signWith no layout the date is written as RFC 3339: 2006-01-02T15:04:05Z.
¶Parse = fn(s)source
Parse reads a date written as RFC 3339, "2006-01-02T15:04:05Z", and returns the seconds since the epoch. The time part may be left out.
¶String = fn(sec)source
String writes the date of the wall clock time sec as RFC 3339.