Generate and return the date in the Gregorian Calendar that appears before the input date.
More...
Generate and return the date in the Gregorian Calendar that appears before the input date.
Returning the correct result requires taking into account the possibility of leap years.
- Parameters
-
[in] | values | : The input contiguous array of shape (:) , of size 3 or larger, of type integer of default kind IK, containing the [year, month, day] triple of the Gregorian calendar.
For the current local date, this triple can be obtained from the Fortran intrinsic date_and_time() or getDateTime().
Only the first three elements (values(1:3) ) are used to compute the output.
The ability to pass longer vectors as input is to allow the output values(1:8) of various functionalities of this module to be passed directly to the procedures under this generic interface.
(optional. It can be present if and only if all other input arguments are missing.) |
[in] | year | : The input scalar, or array of the same shape as other array-like arguments, of type integer of default kind IK, containing the year of the Gregorian calendar.
(optional. It can be present if and only if the input argument values is missing.) |
[in] | month | : The input scalar, or array of the same shape as other array-like arguments, of type integer of default kind IK, containing the month of the Gregorian calendar.
(optional. It must be present if and only if the input argument year is present.) |
[in] | day | : The input scalar, or array of the same shape as other array-like arguments, of type integer of default kind IK, containing the day of the Gregorian calendar.
(optional. It must be present if and only if the input argument month is present.) |
- Returns
dateBefore
: The output vector of size 3
of type integer
of default kind IK, containing the date in the Gregorian Calendar in the format [year, month, day]
that appears before the input date.
Possible calling interfaces ⛓
integer(IK) :: dateBefore(3)
!
Generate and return the date in the Gregorian Calendar that appears before the input date.
This module contains classes and procedures for computing, manipulating, and styling dates and times.
- Warning
- The size of the input argument
values(:)
must be at least 3
and at most 8
.
The input values for the year
, month
, and day
must be valid values.
The input month
must be a number between 1
and 12
.
The input day
must be a number 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.
- See also
- isLastDayInMonth
Example usage ⛓
10 integer(IK) :: Values(
8)
11 type(display_type) :: disp
15 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
16 call disp%show(
"! Determine if a given Gregorian calendar date is the last of the month.")
17 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
21 call disp%show(
"getDateBefore(1582_IK, 10_IK, 15_IK)")
26 call disp%show(
"getDateBefore(1_IK, 1_IK, 1_IK)")
31 call disp%show(
"getDateBefore(-1_IK, 1_IK, 1_IK)")
36 call disp%show(
"getDateBefore(1999_IK, 12_IK, 1_IK)")
41 call disp%show(
"getDateBefore(2000_IK, 1_IK, 1_IK)")
46 call disp%show(
"getDateBefore(2000_IK, 3_IK, 1_IK) ! leap year")
51 call disp%show(
"getDateBefore(1999_IK, 3_IK, 1_IK) ! non-leap year")
56 call disp%show(
"call date_and_time(values = Values(1:8))")
57 call date_and_time(values
= Values(
1:
8))
58 call disp%show(
"SK_'The statement `The Gregorian date before today ('//getStr(Values(1:3))//SK_') was ('//getStr(getDateBefore(Values(1:3)))//SK_').'")
59 call disp%show( SK_
'The statement `The Gregorian date before today ('//getStr(Values(
1:
3))
//SK_
') was ('//getStr(
getDateBefore(Values(
1:
3)))
//SK_
').' , deliml
= SK_
"""" )
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.
Generate and return the conversion of the input value to an output Fortran string,...
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.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
This module contains the generic procedures for converting values of different types and kinds to For...
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 ⛓
35call date_and_time(values
= Values(
1:
8))
36SK_
'The statement `The Gregorian date before today ('//getStr(Values(
1:
3))
//SK_
') was ('//getStr(
getDateBefore(Values(
1:
3)))
//SK_
').'
37"The statement `The Gregorian date before today (2024, 10, 27) was (2024, 10, 26)."
- 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, 00:00 AM, National Institute for Fusion Studies, The University of Texas Austin
Definition at line 3120 of file pm_dateTime.F90.