Skip to content

Conformance Examples 0.1.0 — Transforms: transform-parse_date_time

parse_date_time-no-args-iso8601

parse_date_time with no args parses an ISO 8601 UTC string.

Template

{{ dt | parse_date_time }}

Context

{
    "dt": "1970-01-01T00:00:02Z"
}

Output

1970-01-01T00:00:02Z

parse_date_time-iso8601-utc

parse_date_time with 'iso8601' parses an ISO 8601 UTC string.

Template

{{ dt | parse_date_time: 'iso8601' }}

Context

{
    "dt": "1970-01-01T00:00:02Z"
}

Output

1970-01-01T00:00:02Z

parse_date_time-rfc3339-normalizes-offset

parse_date_time with 'rfc3339' normalizes an explicit offset to UTC.

Template

{{ dt | parse_date_time: 'rfc3339' }}

Context

{
    "dt": "1970-01-01T05:30:00+05:30"
}

Output

1970-01-01T00:00:00Z

parse_date_time-iso8601-normalizes-offset

parse_date_time with 'iso8601' normalizes an explicit offset to UTC.

Template

{{ dt | parse_date_time: 'iso8601' }}

Context

{
    "dt": "1970-01-01T05:30:00+05:30"
}

Output

1970-01-01T00:00:00Z

parse_date_time-iso8601-naive-datetime-as-utc

parse_date_time with 'iso8601' treats a naive datetime (no offset) as UTC.

Template

{{ dt | parse_date_time: 'iso8601' }}

Context

{
    "dt": "1970-01-01T00:00:05"
}

Output

1970-01-01T00:00:05Z

parse_date_time-iso8601-date-only-as-utc-midnight

parse_date_time with 'iso8601' treats a date-only string as UTC midnight.

Template

{{ dt | parse_date_time: 'iso8601' }}

Context

{
    "dt": "1970-01-02"
}

Output

1970-01-02T00:00:00Z

parse_date_time-treat-as-local-false-naive-as-utc

parse_date_time with treatAsLocal='false' treats a naive datetime as UTC.

Template

{{ dt | parse_date_time: 'iso8601' 'false' }}

Context

{
    "dt": "1970-01-01T00:00:05"
}

Output

1970-01-01T00:00:05Z

parse_date_time-rfc1123

parse_date_time with 'rfc1123' parses an RFC 1123 string.

Template

{{ dt | parse_date_time: 'rfc1123' }}

Context

{
    "dt": "Thu, 01 Jan 1970 00:00:02 GMT"
}

Output

1970-01-01T00:00:02Z

parse_date_time-rfc2822

parse_date_time with 'rfc2822' parses an RFC 1123-format string.

Template

{{ dt | parse_date_time: 'rfc2822' }}

Context

{
    "dt": "Thu, 01 Jan 1970 00:00:02 GMT"
}

Output

1970-01-01T00:00:02Z

parse_date_time-unicode-pattern

parse_date_time with a Unicode pattern parses a matching string.

Template

{{ dt | parse_date_time: 'MM/dd/uuuu HH:mm:ss' }}

Context

{
    "dt": "01/01/1970 00:00:05"
}

Output

1970-01-01T00:00:05Z

parse_date_time-unparseable-iso8601-is-null

parse_date_time returns null for a string that cannot be parsed as iso8601.

Template

{{ dt | parse_date_time: 'iso8601' }}

Context

{
    "dt": "not-a-date"
}

Output

null

parse_date_time-unparseable-unicode-pattern-is-null

parse_date_time returns null for a string that does not match the given Unicode pattern.

Template

{{ dt | parse_date_time: 'MM/dd/uuuu HH:mm:ss' }}

Context

{
    "dt": "not-a-date"
}

Output

null

parse_date_time-unparseable-rfc1123-is-null

parse_date_time returns null for a string that cannot be parsed as rfc1123.

Template

{{ dt | parse_date_time: 'rfc1123' }}

Context

{
    "dt": "not-a-date"
}

Output

null

parse_date_time-treat-as-local-true-utc-string

parse_date_time with treatAsLocal='true' and a UTC string normalizes to UTC.

Template

{{ dt | parse_date_time: 'iso8601' 'true' }}

Context

{
    "dt": "1970-01-01T00:00:05Z"
}

Output

1970-01-01T00:00:05Z

Source fixture: transforms/transform-parse_date_time.json