Generate and return the calendarical difference in days between the two input Gregorian dates octuples (Values1(:) - Values2(:)).
More...
Generate and return the calendarical difference in days between the two input Gregorian dates octuples (Values1(:) - Values2(:)).
This algorithm carefully takes into account the possibility of leap years and different time zones.
If Values1
is smaller than Values2
the difference between the two dates is negative.
- Parameters
-
[in] | Values1 | : The input contiguous vector of size 8 of type integer of default kind IK, containing the octuple [year, month, day, zone, hour, minute, seconds, milliseconds] of the Gregorian calendar from which Values2 should be subtracted.
The order of the elements of the vector follows that of the values returned by the Fortran intrinsic date_and_time() .
|
[in] | Values2 | : The input contiguous vector of size 8 of type integer of default kind IK, containing the octuple [year, month, day, zone, hour, minute, seconds, milliseconds] of the Gregorian calendar that should be subtracted from Values1 .
The order of the elements of the vector follows that of the values returned by the Fortran intrinsic date_and_time() .
|
- Returns
dateTimeDiff
: The output scalar of type real
of default kind RK containing the result (in units of days, possible fractional) of the subtraction of Values2
date octuple from Values1
date octuple (Values1 - Values2
).
Possible calling interfaces ⛓
integer(IK) :: Values1(8)
integer(IK) :: Values2(8)
real(RK) :: dateTimeDiff
!
Generate and return the calendarical difference in days between the two input Gregorian dates octuple...
This module contains classes and procedures for computing, manipulating, and styling dates and times.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
- Warning
- The sizes of the two input vector arguments must be the same and equal to
8
.
The input month
must be a number between 1
and 12
.
The input day
must be a number between 1
and 31
and be consistent with the specified month and (leap) year.
The input zone
must be a valid time zone in units of minutes.
The input hour
must be a number between 0
and 23
.
The input minute
must be a number between 0
and 59
.
The input second
must be a number between 0
and 59
.
The input millisecond
must be a number between 0
and 999
.
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.
- See also
- getJulianDay
getDateTimeShifted
Example usage ⛓
12 type(display_type) :: disp
18 call disp%show(
"getDateTime(2000_IK)")
20 call disp%show(
"getDateTimeDiff(getDateTime(), getDateTime(2000_IK))")
22 call disp%show(
"getDateTimeDiff(getDateTime(), getDateTimeShifted(-1.5_RK))")
26 call disp%show(
"getDateTime(1999_IK, 2_IK, 28_IK)")
28 call disp%show(
"getDateTime(1999_IK, 3_IK, 1_IK)")
30 call disp%show(
"getDateTimeDiff(getDateTime(1999_IK, 3_IK, 1_IK), getDateTime(1999_IK, 2_IK, 28_IK)) ! year 1999 is not a leap year.")
34 call disp%show(
"getDateTime(2000_IK, 2_IK, 28_IK)")
36 call disp%show(
"getDateTime(2000_IK, 3_IK, 1_IK)")
38 call disp%show(
"getDateTimeDiff(getDateTime(2000_IK, 3_IK, 1_IK), getDateTime(2000_IK, 2_IK, 28_IK)) ! year 2000 is a leap year.")
42 call disp%show(
"getDateTime(2019_IK, 1_IK, 1_IK)")
44 call disp%show(
"getDateTime(2019_IK, 12_IK, 31_IK)")
46 call disp%show(
"getDateTimeDiff(getDateTime(2019_IK, 1_IK, 1_IK), getDateTime(2019_IK, 12_IK, 31_IK)) ! year 2019 is not a leap year.")
50 call disp%show(
"getDateTime(2020_IK, 1_IK, 1_IK)")
52 call disp%show(
"getDateTime(2020_IK, 12_IK, 31_IK)")
54 call disp%show(
"getDateTimeDiff(getDateTime(2020_IK, 1_IK, 1_IK), getDateTime(2020_IK, 12_IK, 31_IK)) ! year 2020 is a leap year.")
58 call disp%show(
"getDateTime(2020_IK, 1_IK, 1_IK)")
60 call disp%show(
"getDateTime(2021_IK, 1_IK, 1_IK)")
62 call disp%show(
"getDateTimeDiff(getDateTime(2020_IK, 1_IK, 1_IK), getDateTime(2021_IK, 1_IK, 1_IK)) ! year 2020 is a leap year.")
66 call disp%show(
"getDateTime(1_IK, 1_IK, 1_IK, zone = +12_IK * 60_IK)")
68 call disp%show(
"getDateTime(1_IK, 1_IK, 1_IK, zone = -12_IK * 60_IK)")
70 call disp%show(
"getDateTimeDiff(getDateTime(1_IK, 1_IK, 1_IK, zone = +12_IK * 60_IK), getDateTime(1_IK, 1_IK, 1_IK, zone = -12_IK * 60_IK))")
74 call disp%show(
"getDateTime(-1_IK, 1_IK, 1_IK, zone = +12_IK * 60_IK)")
76 call disp%show(
"getDateTime(-1_IK, 1_IK, 1_IK, zone = -12_IK * 60_IK)")
78 call disp%show(
"getDateTimeDiff(getDateTime(-1_IK, 1_IK, 1_IK, zone = -12_IK * 60_IK), getDateTime(-1_IK, 1_IK, 1_IK, zone = +12_IK * 60_IK))")
Generate and return the current or the requested Gregorian date and time shifted by the specified amo...
Generate and return the current or the requested date and time converted to the corresponding Coordin...
Generate and return the current or the requested date and time as an integer-valued array of size 8 o...
This is a generic method of the derived type display_type with pass attribute.
This is a generic method of the derived type display_type with pass attribute.
This module contains classes and procedures for input/output (IO) or generic display operations on st...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
3+2024,
+10,
+28,
+0,
+3,
+32,
+31,
+406
5+2000,
+1,
+1,
+0,
+0,
+0,
+0,
+0
12+1999,
+2,
+28,
+0,
+0,
+0,
+0,
+0
14+1999,
+3,
+1,
+0,
+0,
+0,
+0,
+0
19+2000,
+2,
+28,
+0,
+0,
+0,
+0,
+0
21+2000,
+3,
+1,
+0,
+0,
+0,
+0,
+0
26+2019,
+1,
+1,
+0,
+0,
+0,
+0,
+0
28+2019,
+12,
+31,
+0,
+0,
+0,
+0,
+0
33+2020,
+1,
+1,
+0,
+0,
+0,
+0,
+0
35+2020,
+12,
+31,
+0,
+0,
+0,
+0,
+0
40+2020,
+1,
+1,
+0,
+0,
+0,
+0,
+0
42+2021,
+1,
+1,
+0,
+0,
+0,
+0,
+0
47+1,
+1,
+1,
+720,
+0,
+0,
+0,
+0
49+1,
+1,
+1,
-720,
+0,
+0,
+0,
+0
53getDateTime(
-1_IK,
1_IK,
1_IK, zone
= +12_IK * 60_IK)
54-1,
+1,
+1,
+720,
+0,
+0,
+0,
+0
55getDateTime(
-1_IK,
1_IK,
1_IK, zone
= -12_IK * 60_IK)
56-1,
+1,
+1,
-720,
+0,
+0,
+0,
+0
- 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.
-
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.
-
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.
- Copyright
- Computational Data Science Lab
- Author:
- Amir Shahmoradi, March 22, 2012, 3:59 AM, National Institute for Fusion Studies, The University of Texas Austin
Definition at line 1811 of file pm_dateTime.F90.