Date Time
Last updated
Was this helpful?
Last updated
Was this helpful?
Various operators for parsing and manipulating dates.
This uses Golang's built in time library for parsing and formatting date times.
When not specified, the RFC3339 standard is assumed 2006-01-02T15:04:05Z07:00
for parsing.
To specify a custom parsing format, use the with_dtf
operator. The first parameter sets the datetime parsing format for the expression in the second parameter. The expression can be any valid yq
expression tree.
See the for examples of formatting options.
This uses Golang's built in LoadLocation function to parse timezones strings. See the for more details.
Durations are parsed using Golang's built in function.
You can add durations to time using the +
operator.
Providing a single parameter assumes a standard RFC3339 datetime format. If the target format is not a valid yaml datetime format, the result will be a string tagged node.
Given a sample.yml file of:
then
will output
Use with_dtf to set a custom datetime format for parsing.
Given a sample.yml file of:
then
will output
Given a sample.yml file of:
then
will output
Given a sample.yml file of:
then
will output
Converts from unix time. Note, you don't have to pipe through the tz operator :)
Running
will output
Converts to unix time
Running
will output
Returns a new datetime in the specified timezone. Specify standard IANA Time Zone format or 'utc', 'local'. When given a single parameter, this assumes the datetime is in RFC3339 format.
Given a sample.yml file of:
then
will output
Specify standard IANA Time Zone format or 'utc', 'local'
Given a sample.yml file of:
then
will output
Specify standard IANA Time Zone format or 'utc', 'local'
Given a sample.yml file of:
then
will output
Given a sample.yml file of:
then
will output
Given a sample.yml file of:
then
will output
Given a sample.yml file of:
then
will output
You can embed full expressions in with_dtf if needed.
Given a sample.yml file of:
then
will output
You can subtract durations from dates. Assumes RFC3339 date time format, see for more information.