cosmocalc/units/
time.rs

1use std::ops::{Add, Sub};
2
3use crate::units::{macros::floating_point_unit_impl, traits::FloatingPointUnit};
4
5floating_point_unit_impl! { Gyr }
6floating_point_unit_impl! { Seconds }
7
8pub const SECONDS_PER_YR: f64 = 3.154e+7;
9pub const SECONDS_PER_GYR: f64 = 3.154e+16;
10
11impl From<Seconds> for Gyr {
12    fn from(seconds: Seconds) -> Self {
13        Gyr::new(seconds.0 / SECONDS_PER_GYR)
14    }
15}
16
17impl From<Gyr> for Seconds {
18    fn from(gyrs: Gyr) -> Self {
19        Seconds::new(gyrs.0 * SECONDS_PER_GYR)
20    }
21}