The OpenD Programming Language

SysTime.toISOExtString

Converts this SysTime to a string with the format YYYY-MM-DDTHH:MM:SS.FFFFFFFTZ (where F is fractional seconds and TZ is the time zone).

Default behaviour: Note that the number of digits in the fractional seconds varies with the number of fractional seconds. It's a maximum of 7 (which would be hnsecs), but only has as many as are necessary to hold the correct value (so no trailing zeroes), and if there are no fractional seconds, then there is no decimal point.

The optional parameter "prec" allows to change the default behavior by specifying the precision of the fractional seconds. The accepted values are in the range [-1, 7], where -1 represents the default behavior.

If this SysTime's time zone is std.datetime.timezone.LocalTime, then TZ is empty. If its time zone is UTC, then it is "Z". Otherwise, it is the offset from UTC (e.g. +01:00 or -07:00). Note that the offset from UTC is not enough to uniquely identify the time zone.

Time zone offsets will be in the form +HH:MM or -HH:MM.

  1. string toISOExtString(int prec)
  2. void toISOExtString(W writer, int prec)
    struct SysTime
    const scope
    void
    toISOExtString
    (
    W
    )
    (
    ref W writer
    ,
    int prec = -1
    )
    if (
    isOutputRange!(W, char)
    )

Parameters

writer W

A char accepting output range

prec int

An int representing the desired precision. Acceptable values range from -1 to 7, where -1 represents the default behavior.

Return Value

Type: void

A string when not using an output range; void otherwise.

Examples

import core.time : msecs, hnsecs;
import std.datetime.date : DateTime;

assert(SysTime(DateTime(2010, 7, 4, 7, 6, 12)).toISOExtString() ==
       "2010-07-04T07:06:12");

assert(SysTime(DateTime(1998, 12, 25, 2, 15, 0), msecs(24)).toISOExtString() ==
       "1998-12-25T02:15:00.024");

assert(SysTime(DateTime(0, 1, 5, 23, 9, 59)).toISOExtString() ==
       "0000-01-05T23:09:59");

assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2), hnsecs(520_920)).toISOExtString() ==
       "-0004-01-05T00:00:02.052092");

assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2), hnsecs(520_920)).toISOExtString(4) ==
       "-0004-01-05T00:00:02.0520");

assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2), hnsecs(520_920)).toISOExtString(2) ==
       "-0004-01-05T00:00:02.05");

assert(SysTime(DateTime(-4, 1, 5, 0, 0, 2), hnsecs(520_920)).toISOExtString(7) ==
       "-0004-01-05T00:00:02.0520920");

Meta