ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_dateTime::getJulianDay Interface Reference

Generate and return the Julian Date (Julian Day Number JDN + the fractional part of the day) from the input [year, month, day, zone, hour, minute, second, millisecond] of the Gregorian calendar date. More...

Detailed Description

Generate and return the Julian Date (Julian Day Number JDN + the fractional part of the day) from the input [year, month, day, zone, hour, minute, second, millisecond] of the Gregorian calendar date.

The algrithm of this generic interface is valid for any Gregorian date, even proleptic Gregorian dates including those for negative years. The Julian Day Number, Julian Day, or JD of a particular instant of time is the number of days and fractions of a day since 12 hours Universal Time (Greenwich mean noon) on January 1 of the year -4712, where the year is given in the Julian proleptic calendar. The idea of using this reference date was originally proposed by Joseph Scalizer in 1582 to count years but it was modified by 19th century astronomers to count days.
Julian days are Julian Day Numbers and are not to be confused with Julian dates.
The Julian Day Number (JDN) is expressed as an integer and it represents the number of whole days since the reference instant to noon of that day. For example,

Gregorian Date Time of Day JD
November 24, -4713 start of the day (just after midnight) -0.5
November 24, -4713 noon (start of JD in Gregorian Calendar) 0.0
November 25, -4713 start of the day (just after midnight) +0.5
January 1, -1 start of day 1720694.5
October 15, 1582 start of day (first day of Gregorian reform) 2299160.5
January 1, 1901 start of day (start of the 20th century) 2415385.5
January 1, 1970 start of day (Unix reference date) 2440587.5
December 31, 1979 noon 2444239.0
January 1, 1980 start of the day (just after midnight) 2444239.5
January 1, 1980 noon (Microsoft DOS reference date) 2444240.0
January 1, 1980 midnight commencing January 2 2444240.5


A Julian date is a date in the Julian calendar, similar to a Gregorian date in the Gregorian calendar.
Note that the Julian Day corresponding to a Julian Date does not have the same value as the JD corresponding to the same date in the Gregorian Calendar.

Parameters
[in]year: The input scalar of type integer of default kind IK, containing the year of the Gregorian calendar.
(optional, default = the current value if all input arguments are missing. It can be present only if values is missing.)
[in]month: The input scalar of type integer of default kind IK, containing the month of the year of the Gregorian calendar.
(optional, default = 1 (or the current value if all input arguments are missing). It can be present only if year is present.)
[in]day: The input scalar of type integer of default kind IK, containing the day of the month of the year of the Gregorian calendar.
(optional, default = 1. (or the current value if all input arguments are missing). It can be present only if month is present.)
[in]zone: The input scalar of type integer of default kind IK, containing the time zone of the Gregorian calendar in minutes.
(optional, default = 0 (UTC) (or the current value if all input arguments are missing). It can be present only if day is present.)
[in]hour: The input scalar of type integer of default kind IK, containing the hour of the day of the Gregorian calendar.
(optional, default = 0 (or the current value if all input arguments are missing). It can be present only if zone is present.)
[in]minute: The input scalar of type integer of default kind IK, containing the minute of the hour of the day of the Gregorian calendar.
(optional, default = 0 (or the current value if all input arguments are missing). It can be present only if hour is present.)
[in]second: The input scalar of type integer of default kind IK, containing the second of the minute of the hour of the day of the Gregorian calendar.
(optional, default = 0 (or the current value if all input arguments are missing). It can be present only if minute is present.)
[in]millisecond: The input scalar of type integer of default kind IK, containing the millisecond of the second of the minute of the hour of the day of the Gregorian calendar.
(optional, default = 0 (or the current value if all input arguments are missing). It can be present only if second is present.)
[in]values: The input contiguous vector of maximum size 8 of type integer of default kind IK, containing the values [year, month, day, zone, hour, minute, seconds, milliseconds] of the Gregorian calendar or a subset of the octuple starting with year.
The order of the elements of the vector follows that of the values returned by the Fortran intrinsic date_and_time().
(optional, default = the current date and time. It can be present only if all other arguments are missing.)
Returns
julianDay : The output scalar or array of the same shape as the input array-like arguments (except values), of type real of default kind RK, representing the Julian Date equivalent (in units of days, possibly fractional) of the specified Gregorian Calendar date.


Possible calling interfaces

real(RK) :: julianDay
julianDay = getJulianDay() ! Current Julian Date (JD)
julianDay = getJulianDay(year)
julianDay = getJulianDay(year, month)
julianDay = getJulianDay(year, month, day)
julianDay = getJulianDay(year, month, day, zone)
julianDay = getJulianDay(year, month, day, zone, hour)
julianDay = getJulianDay(year, month, day, zone, hour, minute)
julianDay = getJulianDay(year, month, day, zone, hour, minute, second)
julianDay = getJulianDay(year, month, day, zone, hour, minute, second, millisecond)
julianDay = getJulianDay(values(:)) ! values = [year, month, day, zone, hour, minute, second, millisecond] or a subset starting with `year`.
!
Generate and return the Julian Date (Julian Day Number JDN + the fractional part of the day) from the...
This module contains classes and procedures for computing, manipulating, and styling dates and times.
Warning
The condition 0 < size(values) < 9 must hold.
The input values for [year, month, day, zone, hour, minute, second, millisecond] must be valid and consistent with each other.
For example, the input month must be a number between 1 and 12 and day must be between 1 and 31.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
Remarks
The procedures under this generic interface are always non-elemental and impure when no input argument is present.
The procedures under discussion are elemental.
The procedures under this generic interface are non-elemental when the input argument values(:) is present.
Note
This generic interface is particularly useful for efficient computation of the number of days between two Gregorian dates.
See also
getDateTimeDiff
JPL Gregorian to Julian Day Number Converter
A One-Line Algorithm for Julian Date
Hatcher, 1984, Simple Formulae for Julian Day Numbers and Calendar Dates
Baum, 2017, Date Algorithms


Example usage

1program example
2
3 use pm_kind, only: SK, IK
4 use pm_io, only: display_type
6
7 implicit none
8
9 integer(IK) :: Values(8)
10
11 type(display_type) :: disp
12 disp = display_type(file = "main.out.F90")
13
14 call disp%skip()
15 call disp%show("getJulianDay()")
16 call disp%show( getJulianDay() )
17 call disp%skip()
18
19 call disp%skip()
20 call disp%show("call date_and_time(values = Values)")
21 call date_and_time(values = Values)
22 call disp%show("getJulianDay(Values(1))")
23 call disp%show( getJulianDay(Values(1)) )
24 call disp%show("getJulianDay(Values(1:2))")
25 call disp%show( getJulianDay(Values(1:2)) )
26 call disp%show("getJulianDay(Values(1:3))")
27 call disp%show( getJulianDay(Values(1:3)) )
28 call disp%show("getJulianDay(Values(1:4))")
29 call disp%show( getJulianDay(Values(1:4)) )
30 call disp%show("getJulianDay(Values(1:5))")
31 call disp%show( getJulianDay(Values(1:5)) )
32 call disp%show("getJulianDay(Values(1:6))")
33 call disp%show( getJulianDay(Values(1:6)) )
34 call disp%show("getJulianDay(Values(1:7))")
35 call disp%show( getJulianDay(Values(1:7)) )
36 call disp%show("getJulianDay(Values(1:8))")
37 call disp%show( getJulianDay(Values(1:8)) )
38 call disp%skip()
39
40 call disp%skip()
41 call disp%show("getJulianDay(-4713_IK, 11_IK, 24_IK) ! -0.5")
42 call disp%show( getJulianDay(-4713_IK, 11_IK, 24_IK) )
43 call disp%skip()
44
45 call disp%skip()
46 call disp%show("getJulianDay(-4713_IK, 11_IK, 24_IK, 0_IK, 12_IK) ! 0.0 (until noon)")
47 call disp%show( getJulianDay(-4713_IK, 11_IK, 24_IK, 0_IK, 12_IK) )
48 call disp%skip()
49
50 call disp%skip()
51 call disp%show("getJulianDay(-4713_IK, 11_IK, 25_IK, 0_IK, 0_IK) ! 0.5")
52 call disp%show( getJulianDay(-4713_IK, 11_IK, 25_IK, 0_IK, 0_IK) )
53 call disp%skip()
54
55 call disp%skip()
56 call disp%show("getJulianDay(-1_IK, 1_IK, 1_IK) ! 1720694.5")
57 call disp%show( getJulianDay(-1_IK, 1_IK, 1_IK) )
58 call disp%skip()
59
60 call disp%skip()
61 call disp%show("getJulianDay(1_IK, 1_IK, 1_IK) ! 1721425.5")
62 call disp%show( getJulianDay(1_IK, 1_IK, 1_IK) )
63 call disp%skip()
64
65 call disp%skip()
66 call disp%show("getJulianDay(1582_IK, 10_IK, 15_IK) ! 2299160.5 (The first day of the Gregorian Calendar reform)")
67 call disp%show( getJulianDay(1582_IK, 10_IK, 15_IK) )
68 call disp%skip()
69
70 call disp%skip()
71 call disp%show("getJulianDay(1901_IK, 1_IK, 1_IK) ! 2415385.5 (The start of the 20th century)")
72 call disp%show( getJulianDay(1901_IK, 1_IK, 1_IK) )
73 call disp%skip()
74
75 call disp%skip()
76 call disp%show("getJulianDay(1970_IK, 1_IK, 1_IK) ! 2440587.5 (The Unix reference date)")
77 call disp%show( getJulianDay(1970_IK, 1_IK, 1_IK) )
78 call disp%skip()
79
80 call disp%skip()
81 call disp%show("getJulianDay(2000_IK, 2_IK, 28_IK) ! 2451602.5")
82 call disp%show( getJulianDay(2000_IK, 2_IK, 28_IK) )
83 call disp%skip()
84
85 call disp%skip()
86 call disp%show("getJulianDay(2000_IK, 1_IK, 1_IK) ! 2451544.5")
87 call disp%show( getJulianDay(2000_IK, 1_IK, 1_IK) )
88 call disp%skip()
89
90 call disp%skip()
91 call disp%show("getJulianDay(2000_IK, 1_IK, 1_IK, 0_IK, 18_IK) ! 2451545.25")
92 call disp%show( getJulianDay(2000_IK, 1_IK, 1_IK, 0_IK, 18_IK) )
93 call disp%skip()
94
95 call disp%skip()
96 call disp%show("getJulianDay(2022_IK, 5_IK, 8_IK) ! 2459707.5")
97 call disp%show( getJulianDay(2022_IK, 5_IK, 8_IK) )
98 call disp%skip()
99
100 call disp%skip()
101 call disp%show("getJulianDay(3000_IK, 12_IK, 31_IK) ! 2817151.5")
102 call disp%show( getJulianDay(3000_IK, 12_IK, 31_IK) )
103 call disp%skip()
104
105 call disp%skip()
106 call disp%show("getJulianDay(9999_IK, 12_IK, 31_IK) ! 5373483.5")
107 call disp%show( getJulianDay(9999_IK, 12_IK, 31_IK) )
108 call disp%skip()
109
110 call disp%skip()
111 call disp%show("getJulianDay(99999_IK, 12_IK, 31_IK) ! 38245308.5")
112 call disp%show( getJulianDay(99999_IK, 12_IK, 31_IK) )
113 call disp%skip()
114
115end program example
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
3+2460629.6768355090
4
5
6call date_and_time(values = Values)
7getJulianDay(Values(1))
8+2460310.5000000000
9getJulianDay(Values(1:2))
10+2460615.5000000000
11getJulianDay(Values(1:3))
12+2460628.5000000000
13getJulianDay(Values(1:4))
14+2460628.7500000000
15getJulianDay(Values(1:5))
16+2460629.6666666665
17getJulianDay(Values(1:6))
18+2460629.6763888886
19getJulianDay(Values(1:7))
20+2460629.6768287034
21getJulianDay(Values(1:8))
22+2460629.6768355090
23
24
25getJulianDay(-4713_IK, 11_IK, 24_IK) ! -0.5
26-0.50000000000000000
27
28
29getJulianDay(-4713_IK, 11_IK, 24_IK, 0_IK, 12_IK) ! 0.0 (until noon)
30+0.0000000000000000
31
32
33getJulianDay(-4713_IK, 11_IK, 25_IK, 0_IK, 0_IK) ! 0.5
34+0.50000000000000000
35
36
37getJulianDay(-1_IK, 1_IK, 1_IK) ! 1720694.5
38+1720694.5000000000
39
40
41getJulianDay(1_IK, 1_IK, 1_IK) ! 1721425.5
42+1721425.5000000000
43
44
45getJulianDay(1582_IK, 10_IK, 15_IK) ! 2299160.5 (The first day of the Gregorian Calendar reform)
46+2299160.5000000000
47
48
49getJulianDay(1901_IK, 1_IK, 1_IK) ! 2415385.5 (The start of the 20th century)
50+2415385.5000000000
51
52
53getJulianDay(1970_IK, 1_IK, 1_IK) ! 2440587.5 (The Unix reference date)
54+2440587.5000000000
55
56
57getJulianDay(2000_IK, 2_IK, 28_IK) ! 2451602.5
58+2451602.5000000000
59
60
61getJulianDay(2000_IK, 1_IK, 1_IK) ! 2451544.5
62+2451544.5000000000
63
64
65getJulianDay(2000_IK, 1_IK, 1_IK, 0_IK, 18_IK) ! 2451545.25
66+2451545.2500000000
67
68
69getJulianDay(2022_IK, 5_IK, 8_IK) ! 2459707.5
70+2459707.5000000000
71
72
73getJulianDay(3000_IK, 12_IK, 31_IK) ! 2817151.5
74+2817151.5000000000
75
76
77getJulianDay(9999_IK, 12_IK, 31_IK) ! 5373483.5
78+5373483.5000000000
79
80
81getJulianDay(99999_IK, 12_IK, 31_IK) ! 38245308.5
82+38245308.500000000
83
84
Test:
test_pm_dateTime


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, May 9, 2022, 5:20 AM, Albuquerque, New Mexico

Definition at line 1471 of file pm_dateTime.F90.


The documentation for this interface was generated from the following file: