Generate and return the number of weeks in the specified year or the month of the year of the Gregorian calendar whose majority of days fall within the specified year or month.
More...
Generate and return the number of weeks in the specified year or the month of the year of the Gregorian calendar whose majority of days fall within the specified year or month.
The correct computation of the number of weeks in a year or a number of years requires taking into account the leap years.
Note the number of weeks with majority of days in a given year can be only 53
(for long years) or 52
(for short 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 major weeks within the specified month of the year will be returned.) |
- Returns
countWeeks
: 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 weeks with majority (4 or more) of their days within the specified year
or within the specified month
of the year
.
Possible calling interfaces ⛓
integer(IK) :: countWeeksInYear
integer(IK) :: countWeeksInMonthOfYear
Generate and return the number of weeks in the specified year or the month of the year of the Gregori...
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 ⛓
11 integer(IK),
allocatable :: Year(:)
12 type(display_type) :: disp
16 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
17 call disp%show(
"! Get the count of weeks (with majority of their days) in the given year of the Gregorian calendar.")
18 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
24 call disp%show(
"getCountWeeks(getYear())")
29 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK))")
34 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
35 call disp%show(
"! Get the count of weeks (with majority of their days) in the given month of the year of the Gregorian calendar.")
36 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
40 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 1_IK)")
45 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 2_IK)")
50 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 3_IK)")
55 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 4_IK)")
60 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 5_IK)")
65 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 6_IK)")
70 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 7_IK)")
75 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 8_IK)")
80 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 8_IK)")
85 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 9_IK)")
90 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 10_IK)")
95 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 11_IK)")
100 call disp%show(
"getCountWeeks(getRange(2000_IK, 2020_IK), 12_IK)")
105 call disp%show(
"getCountWeeks(2022_IK, getRange(1_IK, 12_IK))")
Generate minimally-spaced character, integer, real sequences or sequences at fixed intervals of size ...
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 procedures and generic interfaces for generating ranges of discrete character,...
integer(IK) function getYear()
Generate and return the current year 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 ⛓
14+52,
+52,
+52,
+52,
+53,
+52,
+52,
+52,
+52,
+53,
+52,
+52,
+52,
+52,
+52,
+53,
+52,
+52,
+52,
+52,
+53
23+4,
+4,
+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5
27+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4,
+4
31+5,
+5,
+4,
+4,
+4,
+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+5,
+4,
+4
35+4,
+4,
+4,
+4,
+5,
+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+4,
+5,
+4,
+4,
+4,
+4,
+5
39+4,
+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+4
43+5,
+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+4,
+5,
+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4
47+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+4,
+5
51+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+5,
+4
55+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+5,
+4
59+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+4,
+5,
+4,
+4,
+4,
+4
63+4,
+4,
+5,
+5,
+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5
67+5,
+5,
+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+4,
+5,
+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4
71+4,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+5,
+4,
+4,
+4,
+5,
+5,
+4,
+4,
+4,
+5
75+4,
+4,
+5,
+4,
+4,
+5,
+4,
+4,
+5,
+4,
+4,
+5
- 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 3709 of file pm_dateTime.F90.