gregor 0.2.2

Simple implementation of the Gregorian calendar.
Documentation

Gregor

Simple implementation of the Gregorian calendar for Rust.

Gregorian rules are used for all time, which is not historically accurate before 1583.

  • UnixTimestamp represents an instant as a (possibly negative) integer number of seconds since the Unix Epoch, January 1st 1970 at midnight UTC. (There is no sub-second resolution.)
  • DateTime represents a date in the Gegorian calendar and in a given time zone, with components year, month, day, hour, minute, and second.

Time zones

The time zone is generic and part of the type DateTime<Tz> type, so that datetimes in different time zones can not be compared accidentally. Conversions traits are implemented to and from UnixTimestamp for the UTC time zone.

Users can define their own time zone types and implement conversion traits:

struct MyTz {
    //}

impl From<UnixTimestamp> for DateTime<MyTz> {
    fn from(u: UnixTimestamp) -> Self {
        //    }
}

impl From<DateTime<MyTz>> for UnixTimestamp {
    fn from(datetime: DateTime<MyTz>) -> Self {
        //    }
}

#![no_std]

By default the crate uses #![no_std] so that it can be used in freestanding environments. If the system_time Cargo feature is enabled, it uses std to implement conversions to and from std::time::SystemTime.