A datetime library for Elixir providing explicit types, full timezone support, and safe parsing/formatting.
Calendar is a comprehensive datetime library for Elixir that provides explicit, type-safe handling of dates, times, naive datetimes, and timezone-aware datetimes. It solves the problem of ambiguous temporal operations by offering distinct types for each concept and ensures correctness across time zones and formats. While some core functionality is now in Elixir's standard library, Calendar remains valuable for advanced formatting and interoperability features.
Elixir developers who need robust, timezone-aware datetime handling, especially those building applications requiring advanced date/time formatting, parsing of standard formats (like ISO, RFC, Unix), or seamless interoperability with Erlang-style tuples. It's also suitable for projects that must ensure temporal correctness across different time zones.
Developers choose Calendar over alternatives for its explicit type safety, which prevents bugs by separating dates, times, and datetimes, and for its comprehensive timezone support via integration with the tzdata library. Its unique selling point includes advanced, safe string formatting (like strftime) and polymorphic protocols that allow functions to work across compatible types, which are not fully available in the Elixir standard library.
date-time and time zone handling in Elixir
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides distinct Date, Time, NaiveDateTime, and DateTime types to prevent ambiguity and bugs, as emphasized in the philosophy section for correctness.
Integrates with the tzdata library for full timezone handling, enabling accurate conversions and operations across global time zones, demonstrated in DateTime shift examples.
Supports strftime and standard formats like ISO, RFC, Unix, and JS with validation that errors on inappropriate usage, as shown in the Strftime module examples.
Functions work across compatible types, such as using Date operations with DateTime structs, enhancing code reusability and safety, illustrated in the polymorphism section.
Much core functionality, including timezone conversion, is now available in Elixir's standard library since version 1.8, reducing Calendar's necessity for basic use cases.
Relies on the separate tzdata package for timezone data, adding maintenance overhead and potential setup issues, as noted in troubleshooting with ets lookup errors.
While offering advanced formatting, the ecosystem adoption is narrower compared to alternatives like Timex, which might have more community-driven extensions and updates.