yaa110 / rust-persian-calendar

The implementation of the Persian (Solar Hijri) Calendar in Rust

Home Page:https://crates.io/crates/ptime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some leap year timestamps are not correctly calculated

opened this issue · comments

years 1399 and 1403 are leap years

the timespec seconds value for 1399/12/30 and 1400/01/01 are different which is expected behavior
but same values for 1403/12/30 and 1404/01/01 are the same

minimal reproduction:

let time = ptime::from_persian_date(1399, 11, 30).unwrap().to_timespec().sec;
println!("{}", &time);
let time = ptime::from_persian_date(1400, 0, 1).unwrap().to_timespec().sec;
println!("{}", &time);


let time = ptime::from_persian_date(1403, 11, 30).unwrap().to_timespec().sec;
println!("{}", &time);
let time = ptime::from_persian_date(1404, 0, 1).unwrap().to_timespec().sec;
println!("{}", &time);

output

1616198400
1616284800
1742428800
1742428800

There is a project fork in my account
https://github.com/FarzadAT/rust-persian-calendar

I fixed the issue but had to change the api to my likings
you could check the resolved code and new tests and maybe merge if you are ok with the new api