Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed timezone conversion into conversion-function framework #339

Merged
merged 1 commit into from
Feb 12, 2024

Commits on Feb 12, 2024

  1. Embed timezone conversion into conversion-function framework

    This is a new implementation of the timezone conversion functionality on
    top of the conversion-function framework. Previously, we could convert
    `DateTime`s using `dt -> "Europe/Berlin"`, i.e. with a string on the
    right hand side. This required special handling in the type checker,
    the compiler and the Vm.
    
    With this change, we use conversion functions instead. This requires
    users to type `dt -> tz("Europe/Berlin")`, but is conceptually cleaner
    and does not require special handling in the compiler. Well it does
    require special handling in the FFI module for now, but only because we
    don't have anonymous functions / closures yet.
    
    I think this is still a benefitial change overall, as it makes the
    conversion operator conceptually simpler. It can either have a unit on
    the right hand side, or a conversion function.
    
    We also introduce a new `local = tz(get_local_timezone())` function
    which is a bit simpler to type (`dt -> local`) compared to the special
    "local" string before.
    
    Like before, users can still set aliases for timezones. For example:
    
    ```
    let Florida = tz("US/Eastern")
    
    now() -> Florida
    ```
    sharkdp authored and David Peter committed Feb 12, 2024
    Configuration menu
    Copy the full SHA
    0d5e18e View commit details
    Browse the repository at this point in the history