Commit graph

3 commits

Author SHA1 Message Date
Vincent Ambo
b68ef475ee feat(tools/when): support more timestamps with better merging logic
Adds a FieldSet type which defines which parts of a timestamp to merge into
another in a new `mergeTime` function.

With this two timestamps can be merged granularly, enabling more queries like
`Sep 03 18:00` to return useful results (e.g., in this case, in the current year
and location).

Change-Id: I8db161608c5f68c8f9c61de8c6fa46067eced39b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11601
Autosubmit: tazjin <tazjin@tvl.su>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
2024-05-08 13:26:34 +00:00
Vincent Ambo
4bac58e10a feat(tools/when): try to parse input as one segment first
Before getting clever about durations & stuff, try to parse the whole thing at
once. This is useful for plain timestamps that contain spaces, like `2024-01-01
15:00:01` for example.

Change-Id: I50b0ee8488c153b4e6db75abaea409d55c0b92d6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11600
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
2024-05-08 13:26:34 +00:00
Vincent Ambo
00135d1c28 feat(tools/when): simple time-conversion tool
I often need unix timestamps, or have unix timestamps, or need timestamps at
certain relative offsets etc.

This adds a tool called `when` which can do all of this. It has basically no
user interface, you just call it with a time query and it does it if it
understands what you meant. This will get smarter over time as I find more uses.

Example:

    ~> when yesterday 5PM
    Local: Mon 06 May 2024 at 17:00:00 MSK
    UTC:   2024-05-06T14:00:00Z
    UNIX:  1715004000

It supports all kinds of queries already, see the usage for details.

Change-Id: I694ffef7608586acfb1ff8010ac0fac4d9951e2e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11598
Tested-by: BuildkiteCI
Autosubmit: tazjin <tazjin@tvl.su>
Reviewed-by: tazjin <tazjin@tvl.su>
2024-05-08 13:26:34 +00:00