Coverage Report

Created: 2026-10-28 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/sofars-0.6.2/src/cal/cal2jd.rs
Line
Count
Source
1
use crate::consts::{DJM0, IYMIN, MTAB};
2
3
/// Gregorian calendar to Julian Day number
4
0
pub fn cal2jd(iy: i32, im: i32, id: i32) -> Result<(f64, f64), i32> {
5
0
    if iy < IYMIN {
6
0
        return Err(-1);
7
0
    }
8
9
0
    match im {
10
0
        1..=12 => (),
11
0
        _ => return Err(-2),
12
    }
13
14
0
    let ly = if im == 2 && iy % 4 == 0 && (iy % 100 != 0 || iy % 400 == 0) {
15
0
        1
16
    } else {
17
0
        0
18
    };
19
20
0
    if id < 1 || id > (MTAB[(im - 1) as usize] + ly) {
21
0
        return Err(-3);
22
0
    }
23
24
0
    let my = (im - 14) / 12;
25
0
    let iypmy = (iy + my) as i64;
26
0
    let djm0 = DJM0;
27
0
    let djm = ((1461 * (iypmy + 4800)) / 4 + (367 * ((im - 2 - 12 * my) as i64)) / 12
28
0
        - (3 * ((iypmy + 4900) / 100)) / 4
29
0
        + (id as i64)
30
0
        - 2432076) as f64;
31
0
    Ok((djm0, djm))
32
0
}