Generate and return the total number of days in the specified year or the month of the year of the Gregorian calendar.
More...
Generate and return the total number of days in the specified year or the month of the year of the Gregorian calendar.
The correct computation of the number of days in a year or a number of years requires taking into account the leap years.
- Parameters
-
[in] | year | : The input scalar or array of the same shape as other array-like input arguments, of type integer of default kind IK, representing the year of the Gregorian Calendar. |
[in] | month | : The input scalar or array of the same shape as other array-like input arguments, of type integer of default kind IK, representing the month of the year of the Gregorian Calendar.
(optional, if present, the number of days within the specified month of the year will be returned.) |
- Returns
countDays
: The output scalar or array of the same shape as other array-like arguments of type integer
of default kind IK, containing the number of days within the specified year
(or within the specified month
of the year
).
Possible calling interfaces ⛓
integer(IK) :: countDaysInYear
integer(IK) :: countDaysInMonthOfYear
Generate and return the total number of days in the specified year or the month of the year of the Gr...
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 IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
- Warning
- An input argument
year = 0
corresponds to the historic 1 BC notation of the Gregorian calendar.
This is in accordance with the convention in astronomical year numbering and the international standard date system, ISO 8601.
The input argument month
must be a number between 1
and 12
.
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
- dateTimeInt_typer (class constructor)
dateTimeStr_type
Example usage ⛓
12 integer(IK),
allocatable :: Year(:)
13 type(display_type) :: disp
17 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
18 call disp%show(
"! Get the count of days in a given year of the Gregorian calendar.")
19 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
25 call disp%show(
"isLeapYear(getYear())")
27 call disp%show(
"getCountDays(getYear())")
32 call disp%show(
"isLeapYear(2000_IK)")
34 call disp%show(
"getCountDays(2000_IK)")
39 call disp%show(
"isLeapYear(2024_IK)")
41 call disp%show(
"getCountDays(2024_IK)")
46 call disp%show(
"Year = [1_IK, 2_IK, 3_IK, 4_IK]")
47 Year
= [
1_IK,
2_IK,
3_IK,
4_IK]
57 call disp%show(
"Year = -[1_IK, 2_IK, 3_IK, 4_IK]")
58 Year
= -[
1_IK,
2_IK,
3_IK,
4_IK]
68 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
69 call disp%show(
"! Get the count of days in a given month of a given year of the Gregorian calendar.")
70 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
78 call disp%show(
"isLeapYear(getYear())")
80 call disp%show(
"getCountDays(getYear(), getMonth())")
85 call disp%show(
"isLeapYear(2000_IK)")
87 call disp%show(
"getCountDays(2000_IK, 2_IK)")
92 call disp%show(
"isLeapYear(2024_IK)")
94 call disp%show(
"getCountDays(2024_IK, 2_IK)")
99 call disp%show(
"Year = [1_IK, 2_IK, 3_IK, 4_IK]")
100 Year
= [
1_IK,
2_IK,
3_IK,
4_IK]
105 call disp%show(
"getCountDays(Year, 2_IK)")
110 call disp%show(
"Year = -[1_IK, 2_IK, 3_IK, 4_IK]")
111 Year
= -[
1_IK,
2_IK,
3_IK,
4_IK]
116 call disp%show(
"getCountDays(Year, 2_IK)")
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.
integer(IK) function getYear()
Generate and return the current year of the Gregorian calendar.
pure elemental logical(LK) function isLeapYear(year)
Generate and return .true. if the input year is a leap year.
integer(IK) function getMonth()
Generate and return the current month of the Gregorian calendar.
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 ⛓
27Year
= [
1_IK,
2_IK,
3_IK,
4_IK]
36Year
= -[
1_IK,
2_IK,
3_IK,
4_IK]
72Year
= [
1_IK,
2_IK,
3_IK,
4_IK]
81Year
= -[
1_IK,
2_IK,
3_IK,
4_IK]
- 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 3628 of file pm_dateTime.F90.