1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
5
6pub mod utils {
7 pub struct HMS(pub i32, pub i32, pub f64);
8
9 impl From<f64> for HMS {
11 fn from(hour: f64) -> Self {
12 let h = hour.floor() as i32;
13 let m = ((hour - h as f64) * 60.0).floor() as i32;
14 let s = (hour - h as f64 - m as f64 / 60.0) * 3600.0;
15 HMS(h, m, s)
16 }
17 }
18
19 impl std::fmt::Display for HMS {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 let HMS(h, m, s) = self;
22 write!(f, "{:02}h {:02}m {:02.2}s", h, m, s)
23 }
24 }
25
26 pub struct DMS(pub i32, pub i32, pub f64);
27
28 impl From<f64> for DMS {
30 fn from(deg: f64) -> Self {
31 let d = deg.floor() as i32;
32 let m = ((deg - d as f64) * 60.0).floor() as i32;
33 let s = (deg - d as f64 - m as f64 / 60.0) * 3600.0;
34 DMS(d, m, s)
35 }
36 }
37
38 impl std::fmt::Display for DMS {
39 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 let DMS(d, m, s) = self;
41 write!(f, "{:02}° {:02}′ {:02.2}″", d, m, s)
42 }
43 }
44}