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

Conversation

sharkdp
Copy link
Owner

@sharkdp sharkdp commented Feb 12, 2024

This is a new implementation of the timezone conversion functionality on top of the conversion-function framework. Previously, we could convert DateTimes 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

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 sharkdp merged commit 9c778c0 into master Feb 12, 2024
15 checks passed
@sharkdp sharkdp deleted the new-timezone-conversions branch February 12, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant