timelane 0.1.1

Convert between nanoseconds, seconds, days, years... in const.
Documentation
  • Coverage
  • 100%
    32 out of 32 items documented26 out of 26 items with examples
  • Size
  • Source code size: 56.07 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.53 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • kmichel/timelane
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kmichel

Timelane

Convert between nanoseconds, seconds, days, years... in const.

The timelane crate defines lanes of time where each lane works at a different scale: yearly, monthly, daily, etc. Each lane has sequentially numbered marks. The crate implements scaler functions to convert a mark in one lane into a mark in another lane.

For instance, mark 1 in the month lane is mark 1 in the day lane, mark 2 in the month lane is mark 32 in the day lane.

Mark values are signed integers.

Scaler functions can be composed to convert Mark from non-adjacent lanes, like converting a year mark into a second mark.

A mark from a small scale lane can also be converted to a mark in a larger scale lane, like second to year, but you need to chose between rounding down or rounding up. Scaling a second mark to a year mark and then back to a second mark will give the beginning or the end of the year, depending on the rounding mode.

All Scaler functions are const functions. Leap seconds are statically defined.

This library will return incorrect results if the International Earth Rotation and Reference Systems Service declares a new leap second.

However, the last leap second was in 2017 and the General Conference on Weights and Measures resolved to eliminate leap seconds by or before 2035.

  • Years before 1AD use the astronomical year numbering: the year 1BC is mark 0, 2BC is -1...
  • Leap years follow the proleptic gregorian calendar, and are defined even for negative years: 1BC is a leap year.
  • Because of leap seconds, some minutes will contain 61 seconds.
  • Before using this library, make sure you actually want to work with UTC. Many systems use GPS or TAI, which do not include leap seconds.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.