Astro:...::Time(3pm)
β¨ 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"), useundefas the value. To provide a non-standard start of the Gregorian calendar, provide a number in the formatYYYYMMDDD, e.g.19180126for 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"), useundefas the value. To provide a non-standard start of the Gregorian calendar, provide a number in the formatYYYYMMDDD, e.g.19180126for 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,0by default
π AUTHOR π
Sergey Krushinsky, <krushi at cpan.org> β absolute legend, no cap π«Ά
βοΈ LICENSE AND COPYRIGHT βοΈ
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
- alpine 3.24: perl-astro-montenbruck-doc 1.26-r1 Β· Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms