Astro:...::Time(3pm)

πŸ“¦ version 1.26, in alpine 3.24

✨ Astro::Montenbruck::Time ✨

okay bestie, welcome to Astro::Montenbruck::Time β€” a Perl module of time-related routines, straight out of the User Contributed Perl Documentation collection πŸ’– This is Version 0.01, and it's lowkey the moment-keeping backbone of practical astronomy. πŸ•°οΈ


🌸 SYNOPSIS 🌸

use Astro::Montenbruck::Time qw/:all/;

# Convert Gregorian (new-style) date to old-style date
my $j = cal2jd(1799, 6, 6); # Standard Julian date of A.Pushkin's birthday
my $d = jd2cal($j, gregorian => 0) # (1799, 5, 25) = May 26, 1799.

# Julian date in centuries since epoch 2000.0
my $t = jd_cent($j); # -2.0056810403833
...

(no we did not touch a single character of that, it's giving "verbatim or bust" πŸ’…)


πŸ¦‹ DESCRIPTION πŸ¦‹

So this is a library of date/time manipulation routines for practical astronomy. Most of them are built on the so-called Julian date (JD) β€” which is literally the number of days elapsed since mean UT noon of January 1st 4713 BC. Astronomers everywhere adopted this time-measuring system, and honestly? iconic of them. πŸ‘‘

🌈 JD and MJD

A bunch of the routines use the Modified Julian date, which starts at 2000 January 0 (that's 2000 January 1.0) as its starting point. ✨

🧚 Civil year vs astronomical year

okay so there is actual disagreement between astronomers and historians about how to count the years before year 1. Astronomers generally use a zero-based system. The year before year +1 is year zero, and the year before that is year -1. So the year historians call 585 B.C. is, in this world, the year -584. 🀯

In this module, all subroutines accepting a year assume that there is a year zero. So the sequence goes:

BC -3, -2, -1, 0, 1, 2, 3, AD

not me feeling emotional about year zero 😭

πŸŽ€ Date and Time

Time is represented by the fractional part of a day. For example, 7h30m UT is:

(7 + 30 / 60) / 24 = 0.3125

Gregorian calendar πŸ—“οΈ

Civil calendar in most cases means the proleptic Gregorian calendar. It's assumed the Gregorian calendar started at Oct. 4, 1582, when it was first adopted in several European countries. Many other countries still used the older Julian calendar β€” in Soviet Russia, for instance, the Gregorian system was accepted on Jan 26, 1918. See: <https://en.wikipedia.org/wiki/Gregorian_calendar#Adoption_of_the_Gregorian_Calendar> 🫢


πŸ’Ž EXPORTED CONSTANTS πŸ’Ž

  • $SEC_PER_DAY β€” seconds per day (86400) ⏱️
  • $SEC_PER_CEN β€” seconds per century (3155760000) πŸ—“οΈ
  • $J2000 β€” Standard Julian date for start of epoch 2000,0 (2451545) ⭐
  • $J1900 β€” Standard Julian date for start of epoch 1900,0 (2415020) 🌟
  • $GREGORIAN_START β€” Start of Gregorian calendar, YYYYMMDD (15821004) πŸ“…
  • $JD_UNIX_EPOCH β€” Standard Julian date for start of the Unix epoch 🐧

πŸ‘‘ EXPORTED FUNCTIONS πŸ‘‘

  • jd_cent($jd)
  • after_gregorian($year, $month, $date)
  • cal2jd($year, $month, $date)
  • jd2cal($jd)
  • jd0($jd)
  • unix2jd($seconds)
  • jd2unix($jd)
  • jdnow()
  • jd2mjd($jd)
  • mjd2jd($mjd)
  • jd_cent($jd)
  • t1900($jd)
  • jd2dt($jd)
  • jd2te($jd)
  • jd2gst($jd)
  • jd2lst($jd, $lng)

(yes jd_cent is in there twice, and no we're not deleting it, that's just how the list is bestie πŸ™ˆ)


πŸ”₯ FUNCTIONS πŸ”₯

⭐ jd_cent($jd)

Convert Standard Julian Date to centuries passed since epoch 2000.0.

🌸 after_gregorian($year, $month, $date, gregorian_start => $YYYYMMDD )

Does the given date fall in the period after the Gregorian calendar? πŸ€”

Positional Arguments

  • year (astronomic, zero-based)
  • month (1-12)
  • date UTC date (1-31) with hours and minutes as decimal part

Optional Named Arguments

  • gregorian_start β€” start of Gregorian calendar. Default value is 15821004. If the date is Julian ("old style"), use undef as the value. To provide a non-standard start of the Gregorian calendar, provide a number in the format YYYYMMDDD, e.g. 19180126 for Jan 26, 1918.

Returns

true or false=. (that trailing = is literally in the docs, we are simply passing it along, no notes πŸ’€)

🧚 cal2jd($year, $month, $date)

Convert civil date/time to Standard Julian date. πŸ—“οΈβž‘οΈβ­

If the gregorian_start argument is not provided, it's assumed this is a date of the Proleptic Gregorian calendar, which started at Oct. 4, 1582.

Positional Arguments:

  • year (astronomic, zero-based)
  • month (1-12)
  • date UTC date (1-31) with hours and minutes as decimal part

Optional Named Arguments

  • gregorian_start β€” start of Gregorian calendar. Default value is 15821004. If the date is Julian ("old style"), use undef as the value. To provide a non-standard start of the Gregorian calendar, provide a number in the format YYYYMMDDD, e.g. 19180126 for Jan 26, 1918.

Returns

Standard Julian date πŸ“…

πŸŽ€ jd2cal($jd)

Convert Standard Julian date to civil date/time. β­βž‘οΈπŸ—“οΈ

Positional Arguments

Standard Julian Date.

Optional Named Arguments

  • gregorian β€” if true, the result will be old-style (Julian) date.

Returns

A list corresponding to the input values of the cal2jd($year, $month, $date) function. The date is given in the proleptic Gregorian calendar system unless the gregorian flag is set to true. 🫢

πŸ’œ jd0($jd)

Given a Standard Julian Date, calculate the Standard Julian date for midnight of the same date. πŸŒ™

πŸ“ unix2jd($seconds)

Given Unix (POSIX) time, in seconds, convert it to a Standard Julian date. ⏱️➑️⭐

πŸ¦‹ jd2unix($jd)

Given a Standard Julian Date, convert it to Unix time, in seconds since the start of the Unix epoch. 🐧

⚠️ heads up bestie: if the JD falls before the start of the epoch, the result will be negative and thus unusable for Unix-specific functions like localtime(). 😬

✨ jdnow()

Standard Julian date for the current moment. ⏰

🌈 jd2mjd($jd)

Standard to Modified Julian date. πŸ”

🌟 mjd2jd($mjd)

Modified to Standard Julian date. πŸ”

πŸ‘‘ jd_cent($jd)

Given a Standard Julian date, calculate time in centuries since epoch 2000.0. ⭐

🧚 t1900($jd)

Given a Standard Julian date, calculate time in centuries since epoch 1900.0. 🌟

πŸ’Ž jd2gst($jd)

Given a Standard Julian date, calculate True Greenwich Sidereal time. 🌍

πŸ”₯ jd2lst($jd, $lng)

Givan a Standard Julian date, calculate true Local Sidereal time. 🌎 (and yes, "Givan" is exactly what the docs say, we don't editorialise, we respect the typo πŸ’…)

Arguments

  • $jd β€” Standard Julian date
  • $lng β€” Geographic longitude, negative for Eastern longitude, 0 by default

πŸ’– AUTHOR πŸ’–

Sergey Krushinsky, <krushi at cpan.org> β€” absolute legend, no cap 🫢


Copyright 2010-2019 Sergey Krushinsky.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See <http://dev.perl.org/licenses/> for more information. πŸ“œ


and that's the whole page, bestie! πŸŽ€πŸ’– this little writeup ships with perl v5.42.2 and landed on 2026-02-15 β€” go forth and convert those dates, slay πŸ’…βœ¨

πŸ“¦ where this page comes from