hodatime: A fully featured date/time library based on Nodatime

[ bsd3, data, library, time ] [ Propose Tags ] [ Report a vulnerability ]

HodaTime is a full-featured date and time library for Haskell, inspired by Noda Time (and, in turn, Joda Time) and Erik Naggum's /The Long, Painful History of Time/.

It draws a clear line between physical time (instants, durations and intervals on a global time line) and civil time (calendar dates, local times and the calendar-and-zone rules that connect the two), so the type you are holding always tells you exactly what you can and cannot do with it.

Highlights:

  • Multiple calendars (Gregorian, ISO, Julian, Coptic, Persian, Islamic and Hebrew) with lossless conversion between them.

  • Time zones sourced from the operating system (the IANA/Olson database on Unix, the registry on Windows), with explicit resolution of skipped and ambiguous local times across DST transitions.

  • A type-safe, composable pattern system for parsing and formatting that derives a parser and a formatter together from a single field definition.

  • Locale-aware formatting driven by the host system's locale data.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.1.1, 0.2.1.1, 1.0.0.0, 1.1.0.0
Change log CHANGELOG.md
Dependencies array (<0.6), base (>=4.16 && <4.21), binary (<0.9), bytestring (<0.13), containers (<0.8), deepseq (>=1.4 && <1.6), directory (<1.4), exceptions (<0.11), filepath (<1.6), fingertree (>=0.1.3 && <0.2), formatting (<7.3), hashable (>=1.3 && <1.6), mtl (<2.4), parsec (<3.2), text (>=0.11.0.8 && <2.2), unix (<2.9), Win32 (<2.15) [details]
Tested with ghc ==9.4.8 || ==9.6.7 || ==9.8.4 || ==9.10.3
License BSD-3-Clause
Author Jason Johnson
Maintainer <jason.johnson.081@gmail.com>
Uploaded by jason_j at 2026-08-02T14:16:00Z
Category Data, Time
Home page https://github.com/jason-johnson/hodatime
Bug tracker https://github.com/jason-johnson/hodatime/issues
Source repo head: git clone https://github.com/jason-johnson/hodatime
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1305 total (9 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for hodatime-1.1.0.0

[back to package description]

Build Status Hackage

hodatime

A full-featured date and time library for Haskell, inspired by Noda Time (and, in turn, Joda Time) and Erik Naggum's The Long, Painful History of Time.

hodatime draws a clear line between physical time — instants, durations and intervals on a single global timeline — and civil time — calendar dates, local times, and the calendar-and-zone rules that connect the two. The type you are holding always tells you exactly what you can and cannot do with it, so whole classes of date/time mistakes simply do not type-check.

Features

  • Physical vs. civil time, kept distinct at the type level (Instant / Duration / Interval versus CalendarDate / LocalTime / CalendarDateTime).
  • Multiple calendars — Gregorian, ISO, Julian, Coptic, Persian (astronomical Solar Hijri), Islamic (parameterised over the leap-year rule) and Hebrew — with lossless conversion between them.
  • Operating-system time zones — the IANA/Olson database on Unix, the registry on Windows — with explicit resolution of skipped and ambiguous local times across DST transitions.
  • A type-safe, composable pattern system that derives a parser and a formatter together from a single field definition.
  • Locale-aware formatting driven by the host system's locale data.

Example

import Data.HodaTime.Calendar.Gregorian (calendarDate, Month(..))
import Data.HodaTime.CalendarDate (dayOfWeek, withCalendar, CalendarDate)
import Data.HodaTime.Pattern (format)
import Data.HodaTime.Pattern.CalendarDate (pR)
import qualified Data.HodaTime.Calendar.Julian as Julian

-- Dates are smart-constructed; a date that cannot exist is Nothing
valentines = calendarDate 14 February 2024     -- a valid date (Just ...)
notADate   = calendarDate 30 February 2024     -- Nothing

-- Read-only components are plain functions
valentinesDoW = dayOfWeek <$> valentines       -- Just Wednesday

-- Convert losslessly to another calendar (the target is chosen by the result type)
julianChristmas :: Maybe (CalendarDate Julian.Julian)
julianChristmas = withCalendar <$> calendarDate 25 December 2024   -- 12 December 2024 in the Julian calendar

-- Format with a pattern (pR is the ISO-8601 round-trip date pattern)
isoText = format pR <$> calendarDate 23 April 2024                 -- Just "2024-04-23"

Installing

cabal install hodatime

or add hodatime to the build-depends of your package.

Documentation

The full API documentation is on Hackage. Start with the Data.HodaTime module, which gives a guided tour of the core concepts.

Changelog

Release notes are published on the GitHub releases page.

Versioning

Git release tags are the version source of truth. On a commit tagged vX.Y.Z.W, scripts/sync-version.sh sets the Cabal package version to X.Y.Z.W; later commits use X.Y.Z.(W+1). CI runs the script before building or publishing. Run it locally after creating a tag to synchronize hodatime.cabal.

License

BSD-3-Clause. See LICENSE.