pub struct HmsFmt {
pub frac_digits: u8,
}Expand description
Formatter for hours-minutes-seconds (HMS) notation.
HMS is the standard format for right ascension and hour angles in astronomy. The output is always positive; negative angles are wrapped to [0, 24h).
§Fields
frac_digits- Number of decimal places for the seconds component. Use 0 for whole seconds, 2-3 for sub-second precision.
§Output Format
HHʰ MMᵐ SS.ssˢ where:
- Uses Unicode superscript characters (ʰ, ᵐ, ˢ)
- Hours, minutes are whole numbers
- Seconds include decimals per
frac_digits - Negative angles wrap: -1.5h becomes 22h 30m
§Example
use celestial_core::Angle;
use celestial_core::angle::HmsFmt;
let ra = Angle::from_hours(14.5); // 14h 30m 00s
let fmt = HmsFmt { frac_digits: 1 };
assert_eq!(fmt.fmt(ra), "14ʰ 30ᵐ 0.0ˢ");
// Negative angles wrap to positive
let neg = Angle::from_hours(-1.5);
assert_eq!(fmt.fmt(neg), "22ʰ 30ᵐ 0.0ˢ");Fields§
§frac_digits: u8Implementations§
Source§impl HmsFmt
impl HmsFmt
Sourcepub fn fmt(&self, a: Angle) -> String
pub fn fmt(&self, a: Angle) -> String
Formats an angle as hours-minutes-seconds.
Decomposes the angle into integer hours and minutes, with seconds
shown to the precision specified by frac_digits. Negative angles
are wrapped to the range [0, 24h) using Euclidean remainder.
§Arguments
a- The angle to format
§Returns
A string in the format HHʰ MMᵐ SS.ssˢ using Unicode superscript markers.
Auto Trait Implementations§
impl Freeze for HmsFmt
impl RefUnwindSafe for HmsFmt
impl Send for HmsFmt
impl Sync for HmsFmt
impl Unpin for HmsFmt
impl UnsafeUnpin for HmsFmt
impl UnwindSafe for HmsFmt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more