Skip to main content

HmsFmt

Struct HmsFmt 

Source
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: u8

Implementations§

Source§

impl HmsFmt

Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.