Skip to main content

DmsFmt

Struct DmsFmt 

Source
pub struct DmsFmt {
    pub frac_digits: u8,
}
Expand description

Formatter for degrees-minutes-seconds (DMS) notation.

DMS is the standard format for declination, latitude, altitude, and general angular measurements in astronomy. The sign is always explicit.

§Fields

  • frac_digits - Number of decimal places for the arcseconds component. Use 0 for whole arcseconds, 2-3 for sub-arcsecond precision.

§Output Format

±DD° MM' SS.ss" where:

  • Sign is always shown (+ or -)
  • Degrees, arcminutes are whole numbers
  • Arcseconds include decimals per frac_digits

§Example

use celestial_core::Angle;
use celestial_core::angle::DmsFmt;

let dec = Angle::from_degrees(-23.4392);

// Whole arcseconds
let fmt0 = DmsFmt { frac_digits: 0 };
assert_eq!(fmt0.fmt(dec), "-23° 26' 21\"");

// Sub-arcsecond precision (typical for catalogs)
let fmt2 = DmsFmt { frac_digits: 2 };
assert_eq!(fmt2.fmt(dec), "-23° 26' 21.12\"");

Fields§

§frac_digits: u8

Implementations§

Source§

impl DmsFmt

Source

pub fn fmt(&self, a: Angle) -> String

Formats an angle as degrees-minutes-seconds.

Decomposes the angle into integer degrees and arcminutes, with arcseconds shown to the precision specified by frac_digits.

§Arguments
  • a - The angle to format
§Returns

A string in the format ±DD° MM' SS.ss".

Auto Trait Implementations§

§

impl Freeze for DmsFmt

§

impl RefUnwindSafe for DmsFmt

§

impl Send for DmsFmt

§

impl Sync for DmsFmt

§

impl Unpin for DmsFmt

§

impl UnwindSafe for DmsFmt

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.