DateTime::Astro(3pm)

πŸ“¦ version 1.04, in alpine 3.24

🌸 NAME 🌸

Okay so bestie, welcome to DateTime::Astro(3pm) β€” the User Contributed Perl Documentation page for DateTime::Astro. The NAME-line vibe is literally: DateTime::Astro - Functions For Astromical Calendars. Yes, "Astromical" is spelled like that on the page, and we are respecting the icon πŸ˜ŒπŸ’… periodt.

✨ DESCRIPTION ✨

So DateTime::Astro implements functions used in astronomical calendars, like the calculation of lunar longitudea and solar longitude. (Yes, "longitudea" is the original's spelling β€” I'm not fixing it, I'm preserving the artifact πŸ’….)

This module is best used in environments where a C compiler and the MPFR arbitrary precision math library is installed. It can fallback to using Math::BigInt, but that would pretty much render it useless because of its speed and loss of accuracy that may creep up while doing Perl to C struct conversions.

πŸ’€ DISCLAIMER πŸ’€

Vibe check: this module works, but there are several caveats you should be aware of:

🚨 MPFR Is Required / PurePerl Version Not Functional 🚨

There /is/ a HALF BAKED Pure Perl implmentation bundled with this distribution, but at this point please consider it UNUSABLE. This sort of calculation requires the speed and efficiency of a C library anyway.

As such, no cap, you HAVE to have MPFR installed correctly in your system. Please consult your local package manager, or http://mpfr.org.

Patches to make the pure perl version work better is always welcome.

⏰ 17 solar terms are still off by ~ 5 minutes ⏰

I've tried very hard to correctly calculate the solar term dates with this module, but I still get 17 instances in about 130 years worth of solar terms, where the dates are off by an average of about 5 minutes β€” and these usually fall at right about midnight, causing day-based comparisons to be off by 1.

I'm sure there's something that's causing a round off somwhere. If you're up to it, please see xt/101_solar_terms.t and see if you can fix it for me!

πŸ› οΈ FUNCTIONS πŸ› οΈ

Okay bestie, here's the full function roster, in the exact order the page gives them. I'm keeping every signature character-for-character, even the ones with no description. πŸ’–

  • BACKEND() β€” Returns 'XS' or 'PP', noting the current backend.
  • dt_from_moment($moment) β€” Given a moment (days since rd + fractional seconds), returns a DateTime object in UTC.
  • dynamical_moment($moment) β€” Computes the moment value from the given moemnt (the page's spelling, not mine 😭), taking into account the ephemeris correction.
  • dynamical_moment_from_dt($dt) β€” Computes the moment value from a DateTime object, taking into account the ephemeris correction.
  • ephemeris_correction($moment) β€” Computes the ephemeris correction on a given moment.
  • gregorian_components_from_rd($rd_days) β€” Computes year, month, date from RD value.
  • gregorian_year_from_rd($rd_days) β€” Computes year from RD value.
  • julian_centuries($dt) β€” Computes the julian centuries for given DateTime object.
  • julian_centuries_from_moment($moment) β€” Computes the julian centuries for given moment.
  • lunar_phase($dt) β€” Computes the lunar phase for given DateTime object.
  • lunar_phase_from_moment($moment) β€” Computes the lunar phase for given moment.
  • polynomial($x, ...) β€” Computes the polynomical expression using $x as the variable. The left most argument is the constant, and each successive argument is the coefficient for the next power of $x.
  • ymd_seconds_from_moment($moment) β€” Computes the gregorian components (year, month, day) from the RD date, and the number of seconds from the fractional part.
  • lunar_longitude($dt) β€” Returns the Moon's longitude on the given date $dt.
  • lunar_longitude_from_moment($moment) β€” Returns the Moon's longitude on the given moment $moment.
  • moment($dt) β€” Returns the date $dt expressed in moment.
  • nth_new_moon($n) β€” Returns the $n-th new moon, in $moment.

Currently the new moons dates are accurate to about within +/- 60 seconds of the actual new moon for modern dates.

For older dates, the accuraccy degrades a bit to about +/- 5 minutes.

  • new_moon_after($dt) β€” No description in the original β€” just the name/signature as listed.
  • new_moon_before($dt) β€” No description in the original β€” just the name/signature as listed.
  • solar_longitude($dt) β€” Returns the Sun's longitude on the given date $dt.
  • solar_longitude_from_moment($moment) β€” Returns the Sun's longitude on the given moment $moment.
  • new_moon_after_from_moment β€” No description in the original β€” just the name as listed.
  • new_moon_before_from_moment β€” No description in the original β€” just the name as listed.
  • solar_longitude_after β€” No description in the original β€” just the name as listed.
  • solar_longitude_after_from_moment β€” No description in the original β€” just the name as listed.
  • solar_longitude_before β€” No description in the original β€” just the name as listed.
  • solar_longitude_before_from_moment β€” No description in the original β€” just the name as listed.

πŸŽ€ CONSTANTS πŸŽ€

  • MEAN_SYNODIC_MONTH β€” Mean time (in moment) between new moons.
  • MEAN_TROPICAL_YEAR β€” Mean time (in moment) between a full year (time for the Earth to go around the sun).

πŸ“œ LICENSE πŸ“œ

This library is available under Artistic License v2, and is:

Copyright (C) 2012  Daisuke Maki C<< <daisuke@endeworks.jp> >>

πŸ’Œ AUTHOR πŸ’Œ

Daisuke Maki β€” "<daisuke@endeworks.jp>".


πŸ’– And that's the whole DateTime::Astro(3pm) page, bestie! Cute footer sign-off: source/version is perl v5.42.2, date is 2026-02-15, and the manual is DateTime::Astro(3pm) β€” slay, bye! πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from