Class: Horologium::Representations::ModifiedJulianDate
- Inherits:
-
Object
- Object
- Horologium::Representations::ModifiedJulianDate
- Defined in:
- lib/horologium/representations/modified_julian_date.rb,
sig/horologium/representations/modified_julian_date.rbs
Overview
The Modified Julian Date: the Julian Date counted from midnight on 17 November 1858 instead of noon on 1 January 4713 BC, so that a modern date is a five-digit number and a day begins at midnight. Geodesy and Earth orientation data are published in it.
It is the same instant, written smaller, and the smaller number is worth something: a Float spends fewer of its digits on the day count, so about 2 microseconds are left for the fraction of a day where a Julian Date has about 40. The lossless shapes of JulianDate.parse are still the way to give one exactly.
Constant Summary collapse
- DAYS_AFTER_JULIAN_DATE_ORIGIN =
The days between the two origins: the Modified Julian Date origin falls this many days after the Julian Date origin, so a Modified Julian Date is the Julian Date minus this.
Rational(4_800_001, 2)
- OFFSETS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The offset at each precision, built once, so a reading does not build it again every time.
Numeric::Precision::NAMES.map do |precision| [ precision, Numeric::Precision.build(DAYS_AFTER_JULIAN_DATE_ORIGIN, precision) ] end.to_h.freeze
Class Method Summary collapse
-
.parse(value, low, scale, precision) ⇒ Horologium::Numeric::TwoPartFloat, Horologium::Numeric::Exact
A Modified Julian Date as it was given, as a Julian Date in days, at the precision asked for.
-
.render(reading, output) ⇒ Float, ...
The Modified Julian Date, in the type asked for.
Class Method Details
.parse(value, low, scale, precision) ⇒ Horologium::Numeric::TwoPartFloat, Horologium::Numeric::Exact
A Modified Julian Date as it was given, as a Julian Date in days, at the precision asked for. It takes the shapes JulianDate.parse takes, and adds the days between the two origins.
85 86 87 88 89 90 |
# File 'lib/horologium/representations/modified_julian_date.rb', line 85 def parse(value, low, scale, precision) Numeric::Precision.add( JulianDate.parse(value, low, scale, precision), offset(precision) ) end |
.render(reading, output) ⇒ Float, ...
The Modified Julian Date, in the type asked for. The types are the ones a Julian Date comes out as, JulianDate::OUTPUTS, and they mean the same here.
52 53 54 55 56 57 58 59 60 |
# File 'lib/horologium/representations/modified_julian_date.rb', line 52 def render(reading, output) JulianDate.render_value( Numeric::Precision.subtract( reading.value, offset(reading.precision) ), output ) end |