I get different Julian dates for the same Gregorian date depending on the API. For the Gregorian date 2025-02-05:
Which is correct?
GLib:
#include <glib-2.0/glib.h>
/* gcc main.c -I/usr/include `pkg-config --cflags glib-2.0` `pkg-config --libs glib-2.0` */
int main(int argc, char *argv[]) {
GDate *dmy = g_date_new_dmy(5,2,2025);
guint32 my_julian = g_date_get_julian(dmy);
GDateDay day = g_date_get_day(dmy);
GDateMonth month = g_date_get_month(dmy);
GDateYear year = g_date_get_year(dmy);
g_print("YYYY-MM-DD = %02u-%02u-%02u\n",year, month, day);
g_print("Julian = %u\n", my_julian);
return 0;
}
Output:
YYYY-MM-DD = 2025-02-05
Julian = 739287
SQLite:
/* From an SQLite session */
SELECT julianday('2025-02-05');
2460711.5
A Julian representation is simply a count of days since some fixed day in the past (the epoch).
GLib.Date
doesn't return true Julian date as it doesn't use the standard Julian period epoch value, i.e. "Jan 1, 4713 BC". Instead, GLib.Date
uses "Jan 1, 1 AD" as epoch. [1] [2]
The return value from sqlite3 is in line with this US Navy site, both use "Jan 1, 4713 BC" as the epoch for the current Julian period.