Function dcf77_chrono::from_dcf77
source · pub fn from_dcf77(input: u64) -> Result<DCF77, Error>
Expand description
Decodes the date and metadata out of a dcf77 bit field
A DCF77 bitfield is given as input and a DCF77 struct is returned when successful
Examples
use chrono::prelude::*;
use dcf77_chrono::*;
let original_test_time = Utc::now() - chrono::Duration::minutes(Utc::now().time().minute().into());
let test_time = DCF77 {
date: original_test_time,
antenna: false,
announce_daily_saving_time: false,
daily_saving_time: false,
standard_time: false,
bit_leap_second: false
};
match to_dcf77(test_time) {
Ok(coded_minutes) => {
match from_dcf77(coded_minutes) {
Ok(decoded_minutes) => {
assert!(test_time.date.time() == decoded_minutes.date.time())
}
Err(input) => {
println!("Error on decoding 0x{:X} to dcf77 {:?}", coded_minutes, input);
}
}
}
Err(coded_hour) => {
println!("Error on creating the dcf77 {:?}", coded_hour);
}
}