Glistix fork of birl, a Date / Time handling library
  • Gleam 73.2%
  • Erlang 14.4%
  • Nix 7.6%
  • Rust 3.6%
  • JavaScript 1.1%
Find a file
2025-03-14 21:17:56 -03:00
.github/workflows add ci 2024-04-26 20:52:33 -03:00
external update stdlib to 0.38.0 2024-08-01 01:45:42 -03:00
src further formatting 2024-08-01 01:39:31 -03:00
test update package to new patching 2025-03-14 21:04:48 -03:00
zones-provider new interval module, updated zones 2024-03-21 13:28:50 +03:30
.gitignore added support for timezones 2023-09-18 23:17:21 +03:30
.gitmodules add stdlib submodule 2024-04-23 02:05:30 -03:00
banner.png some docs changes 2023-11-21 21:24:35 +03:30
default.nix add nix files 2024-04-23 02:14:16 -03:00
flake.lock update flake 2025-03-14 21:08:35 -03:00
flake.nix update flake 2025-03-14 21:08:35 -03:00
gleam.toml glistix link on gleam.toml 2025-03-14 21:04:48 -03:00
icon.png some docs changes 2023-11-21 21:24:35 +03:30
LICENSE fixed some bugs, added some functions, added LICENSE 2023-05-05 14:25:20 +03:30
manifest.toml update package to new patching 2025-03-14 21:04:48 -03:00
NOTICE add NOTICE 2024-04-15 15:49:25 -03:00
README.md readme disclaimer 2025-03-14 21:17:56 -03:00
shell.nix add nix files 2024-04-23 02:14:16 -03:00
update-zones.sh minor change to the shell script 2023-10-03 12:35:02 +03:30

birl

Package Version Hex Docs Nix-compatible

glistix-birl

Mirrors: GitHub | Codeberg

Glistix fork of birl, a Date/Time handling library for Gleam.

Adds support for the Nix target. For that, implements the algorithms at http://howardhinnant.github.io/date_algorithms.html.

Its documentation can be found at https://hexdocs.pm/glistix_birl.

Warning

Disclaimer: This is an unofficial fork of birl and we are not affiliated with its authors. If you are not using Glistix with the Nix target, consider using the original birl package directly instead.

Notes

Due to purity constraints, the Nix target cannot access the local timezone of the system. However, it can access the current time, but only outside pure-eval mode (otherwise it's assumed to be Jan 1, 1970, or 0 in Unix time). Do note, however, that accessing the current time can only be done once per evaluation (later calls to now() always return the same result).

Otherwise, the functions and algorithms should work just fine (just try not to depend on the current time).

Quick start

nix develop   # Optional: Enter a shell with glistix
glistix run   # Run the project
glistix test  # Run the tests

Installation

Installation

For the most recent instructions, please see the Glistix handbook.

You can use this fork by running glistix add birl followed by adding the line below to your Glistix project's gleam.toml file (as of Glistix v0.7.0):

[glistix.preview.patch]
# ... Existing patches ...
# Add this line:
birl = { name = "glistix_birl", version = ">= 1.0.0 and < 2.0.0" }

This ensures transitive dependencies on birl will also use the patch.

Keep in mind that patches only have an effect on end users' projects - they are ignored when publishing a package to Hex, so end users are responsible for any patches their dependencies may need.

If your project or package is only meant for the Nix target, you can also use this fork in [dependencies] directly through glistix add glistix_birl in order to not rely on patching. However, the patch above is still going to be necessary for end users to fix other dependencies which depend on birl.

Usage

import birl
import birl/duration

pub fn main() {
    let now = birl.now()
    let two_weeks_later = birl.add(now, duration.weeks(2))
    birl.to_iso8601(two_weeks_later)
}