Skip to content

Conformance Examples 0.1.0 — Transforms: transform-format_date_time

format_date_time-no-args-iso8601

format_date_time with no args renders ISO 8601 in UTC.

Template

{{ ts | as_date_time: 'seconds' | format_date_time }}

Context

{
    "ts": 2
}

Output

1970-01-01T00:00:02Z

format_date_time-iso8601

format_date_time with 'iso8601' renders ISO 8601 in UTC.

Template

{{ ts | as_date_time: 'seconds' | format_date_time: 'iso8601' }}

Context

{
    "ts": 2
}

Output

1970-01-01T00:00:02Z

format_date_time-rfc3339

format_date_time with 'rfc3339' renders ISO 8601 in UTC.

Template

{{ ts | as_date_time: 'seconds' | format_date_time: 'rfc3339' }}

Context

{
    "ts": 2
}

Output

1970-01-01T00:00:02Z

format_date_time-explicit-timezone

format_date_time with an explicit time zone shifts the rendered offset.

Template

{{ ts | as_date_time: 'seconds' | format_date_time: 'iso8601' 'UTC-05:00' }}

Context

{
    "ts": 0
}

Output

1969-12-31T19:00:00-05:00

format_date_time-rfc1123

format_date_time with 'rfc1123' renders an RFC 1123 string in UTC.

Template

{{ ts | as_date_time: 'seconds' | format_date_time: 'rfc1123' }}

Context

{
    "ts": 2
}

Output

Thu, 1 Jan 1970 00:00:02 GMT

format_date_time-rfc2822

format_date_time with 'rfc2822' renders an RFC 1123-format string in UTC.

Template

{{ ts | as_date_time: 'seconds' | format_date_time: 'rfc2822' }}

Context

{
    "ts": 2
}

Output

Thu, 1 Jan 1970 00:00:02 GMT

format_date_time-unicode-pattern

format_date_time with a Unicode pattern renders that pattern in UTC.

Template

{{ ts | as_date_time: 'seconds' | format_date_time: 'MM/dd/uuuu HH:mm:ss' }}

Context

{
    "ts": 5
}

Output

01/01/1970 00:00:05

format_date_time-non-datetime-input-is-null

format_date_time returns null when the input is not a DateTime.

Template

{{ s | format_date_time }}

Context

{
    "s": "hello"
}

Output

null

format_date_time-invalid-timezone-is-null

An invalid time zone identifier is a soft failure, so format_date_time yields null.

Template

{{ ts | as_date_time: 'seconds' | format_date_time: 'iso8601' 'Not/AZone' }}

Context

{
    "ts": 0
}

Output

null

format_date_time-invalid-unicode-pattern-is-null

An invalid Unicode format pattern is a soft failure, so format_date_time yields null.

Template

{{ ts | as_date_time: 'seconds' | format_date_time: 'G' }}

Context

{
    "ts": 0
}

Output

null

Source fixture: transforms/transform-format_date_time.json