Skip to content

Commit f9a29c7

Browse files
authored
Made Location::try_new public (#7775)
In order to get observational islamic date for locations other than `MECCA` and `CAIRO` Example: ```rust let new_york = Location::try_new(40.7, -74.0, 10.0, -5.0 / 24.0).unwrap(); let fixed = fixed_from_gregorian(2026, 3, 13); let (year, month, day) = observational_islamic_from_fixed(fixed, new_york); println!("Observational NYC: {day}/{month}/{year}"); ``` ## Changelog calendrical_calculations: Changed `Location::try_new` from `pub(crate)` to `pub` - New Methods: `Location::try_new()` - New errors: `LocationOutOfBoundsError`
1 parent 016c46b commit f9a29c7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

utils/calendrical_calculations/src/astronomy.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ pub struct Location {
4444
pub(crate) longitude: f64,
4545
/// elevation in meters
4646
pub(crate) elevation: f64,
47-
/// UTC timezone offset in fractional days (1 hr = 1.0 / 24.0 day)
47+
/// UTC timezone offset in fractional days (1 hr = 1.0 / 24.0 day),
48+
/// within the range (-12.0 / 24.0) to (14.0 / 24.0)
4849
pub(crate) utc_offset: f64,
4950
}
5051

@@ -77,10 +78,10 @@ pub const WINTER: f64 = 270.0;
7778
pub const NEW_MOON_ZERO: Moment = Moment::new(11.458922815770109);
7879

7980
impl Location {
80-
/// Create a location; latitude is from -90 to 90, and longitude is from -180 to 180;
81+
/// Create a location; latitude is from -90 to 90, longitude is from -180 to 180,
82+
/// and `utc_offset` is from (-12.0 / 24.0) to (14.0 / 24.0);
8183
/// attempting to create a location outside of these bounds will result in a [`LocationOutOfBoundsError`].
82-
#[allow(dead_code)] // TODO: Remove dead_code tag after use
83-
pub(crate) fn try_new(
84+
pub fn try_new(
8485
latitude: f64,
8586
longitude: f64,
8687
elevation: f64,

utils/calendrical_calculations/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub mod chinese_based;
3737
/// The Coptic calendar
3838
pub mod coptic;
3939
/// Error handling
40-
mod error;
40+
pub mod error;
4141
/// The Ethiopian calendar
4242
pub mod ethiopian;
4343
/// The Gregorian calendar

0 commit comments

Comments
 (0)