Added date subtract support

This commit is contained in:
Mike Farah
2022-02-14 15:29:17 +11:00
parent 246d1af8d6
commit 778cbd348a
11 changed files with 181 additions and 40 deletions
+4 -5
View File
@@ -5,16 +5,15 @@ Various operators for parsing and manipulating dates.
## Date time formattings
This uses the golangs built in time library for parsing and formatting date times.
When not specified, the RFC3339 standard is assumed `2006-01-02T15:04:05Z07:00`.
When not specified, the RFC3339 standard is assumed `2006-01-02T15:04:05Z07:00` for parsing.
To use a custom format, use the `with_dtformat` operator to set the formatting context. Expressions in the second parameter then assume that date format.
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.
```bash
yq 'with_dtformat("myformat"; .a + "3h" | tz("Australia/Melbourne"))'
yq 'with_dtf("myformat"; .a + "3h" | tz("Australia/Melbourne"))'
```
See https://pkg.go.dev/time#pkg-constants for more examples.
See https://pkg.go.dev/time#pkg-constants for examples of formatting options.
## Timezones