Skip to content

Extend duration function to allow retrieving the unit #20

Open
@bartjkdp

Description

@bartjkdp

This is a proposal to extend the duration function in order to allow retrieving the unit. You can use this as follows:

{"duration": [{"-": [{"date": "2025-02-10"}, {"date": "1978-01-01"}]}, "days"]}

This returns:

17207

This can be used for example to calculate the day of the week for a given date:

{"%": [{"duration": [{"-": [{"date": "2025-02-10"}, {"date": "1978-01-01"}]}, "days"]}, 7]}

This returns:

1

In this calculation this represents Monday. This is because 1978-01-01 is a Sunday (0).

Curious to hear if you like this solution direction and if I can finish the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions