astro-rust
                                
                                 astro-rust copied to clipboard
                                
                                    astro-rust copied to clipboard
                            
                            
                            
                        decimal_day is broken
The existing code in decimal_day is incorrect. It doesn't divide minutes by minutes/day, but by minutes per hour, and seconds not by seconds/day but by seconds/minute.
Corrected version:
fn decimal_day(day: &astro::time::DayOfMonth) -> f64 {
    (day.day as f64)
 + (day.hr as f64) / 24.0
  + (day.min as f64) / (60.0 * 24.0)
  + day.sec / (60.0 * 60.0 * 24.0)
  - day.time_zone / 24.0
}
With this fix, the following program will print the correct Julian Ephemeris Date for UTC now.
extern crate astro;
extern crate chrono;
use chrono::prelude::*;
fn decimal_day(day: &astro::time::DayOfMonth) -> f64 {
    (day.day as f64)
  + (day.hr as f64) / 24.0
  + (day.min as f64) / (60.0 * 24.0)
  + day.sec / (60.0 * 60.0 * 24.0)
  - day.time_zone / 24.0
}
fn tm_to_date(now: DateTime<Utc>) -> astro::time::Date
{
    let day_of_month = astro::time::DayOfMonth {
        day : now.day() as u8,
        hr  : now.hour() as u8,
        min : now.minute() as u8,
        sec : 0f64,//now.second() as f64,
        time_zone : 0.0 };
    astro::time::Date {
        year : now.year() as i16,
        month : now.month() as u8,
        decimal_day : decimal_day(&day_of_month),
        cal_type : astro::time::CalType::Gregorian }
}
fn now_utc() -> astro::time::Date
{
    let utc: DateTime<Utc> = Utc::now(); 
    println!("{:?}", utc);
    tm_to_date(utc)
}
fn main() {
    let date = now_utc();
    let julian_day = astro::time::julian_day(&date);
    let delta_t = astro::time::delta_t(date.year as i32, date.month);
    let julian_ephm_day = astro::time::julian_ephemeris_day(julian_day, delta_t);
    println!("{}", julian_ephm_day);
}
Confirmed this problem
@meshula Thanks for the report! I won't be able to fix this anytime soon, please feel free to open a PR!
Since this has not yet been fixed, I've submitted a PR (#10).
Thanks!
Has this issue been fixed? Or is it open for a reason?
I created it, so I'll close it.