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

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...

Detailed Description

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

use pm_kind, only: IK
integer(IK) :: countWeeksInYear
integer(IK) :: countWeeksInMonthOfYear
countWeeksInYear = getCountWeeks(year)
countWeeksInMonthOfYear = getCountWeeks(year, month)
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...
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
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.
Remarks
The procedures under discussion are elemental.
See also
dateTimeInt_typer (class constructor)
dateTimeStr_type


Example usage

1program example
2
3 use pm_kind, only: SK, IK
4 use pm_io, only: display_type
6 use pm_arrayRange, only: getRange
7 use pm_dateTime, only: getYear
8
9 implicit none
10
11 integer(IK), allocatable :: Year(:)
12 type(display_type) :: disp
13 disp = display_type(file = "main.out.F90")
14
15 call disp%skip()
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("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
19 call disp%skip()
20
21 call disp%skip()
22 call disp%show("getYear()")
23 call disp%show( getYear() )
24 call disp%show("getCountWeeks(getYear())")
26 call disp%skip()
27
28 call disp%skip()
29 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK))")
30 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK)) )
31 call disp%skip()
32
33 call disp%skip()
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("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
37 call disp%skip()
38
39 call disp%skip()
40 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 1_IK)")
41 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 1_IK) )
42 call disp%skip()
43
44 call disp%skip()
45 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 2_IK)")
46 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 2_IK) )
47 call disp%skip()
48
49 call disp%skip()
50 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 3_IK)")
51 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 3_IK) )
52 call disp%skip()
53
54 call disp%skip()
55 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 4_IK)")
56 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 4_IK) )
57 call disp%skip()
58
59 call disp%skip()
60 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 5_IK)")
61 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 5_IK) )
62 call disp%skip()
63
64 call disp%skip()
65 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 6_IK)")
66 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 6_IK) )
67 call disp%skip()
68
69 call disp%skip()
70 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 7_IK)")
71 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 7_IK) )
72 call disp%skip()
73
74 call disp%skip()
75 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 8_IK)")
76 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 8_IK) )
77 call disp%skip()
78
79 call disp%skip()
80 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 8_IK)")
81 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 8_IK) )
82 call disp%skip()
83
84 call disp%skip()
85 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 9_IK)")
86 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 9_IK) )
87 call disp%skip()
88
89 call disp%skip()
90 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 10_IK)")
91 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 10_IK) )
92 call disp%skip()
93
94 call disp%skip()
95 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 11_IK)")
96 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 11_IK) )
97 call disp%skip()
98
99 call disp%skip()
100 call disp%show("getCountWeeks(getRange(2000_IK, 2020_IK), 12_IK)")
101 call disp%show( getCountWeeks(getRange(2000_IK, 2020_IK), 12_IK) )
102 call disp%skip()
103
104 call disp%skip()
105 call disp%show("getCountWeeks(2022_IK, getRange(1_IK, 12_IK))")
106 call disp%show( getCountWeeks(2022_IK, getRange(1_IK, 12_IK)) )
107 call disp%skip()
108
109end program example
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.
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 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...
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
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
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3! Get the count of weeks (with majority of their days) in the given year of the Gregorian calendar.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
8+2024
10+52
11
12
13getCountWeeks(getRange(2000_IK, 2020_IK))
14+52, +52, +52, +52, +53, +52, +52, +52, +52, +53, +52, +52, +52, +52, +52, +53, +52, +52, +52, +52, +53
15
16
17!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18! Get the count of weeks (with majority of their days) in the given month of the year of the Gregorian calendar.
19!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20
21
22getCountWeeks(getRange(2000_IK, 2020_IK), 1_IK)
23+4, +4, +5, +5, +5, +4, +4, +4, +5, +5, +4, +4, +4, +5, +5, +5, +4, +4, +4, +5, +5
24
25
26getCountWeeks(getRange(2000_IK, 2020_IK), 2_IK)
27+4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4, +4
28
29
30getCountWeeks(getRange(2000_IK, 2020_IK), 3_IK)
31+5, +5, +4, +4, +4, +5, +5, +5, +4, +4, +4, +5, +5, +4, +4, +4, +5, +5, +5, +4, +4
32
33
34getCountWeeks(getRange(2000_IK, 2020_IK), 4_IK)
35+4, +4, +4, +4, +5, +4, +4, +4, +4, +5, +5, +4, +4, +4, +4, +5, +4, +4, +4, +4, +5
36
37
38getCountWeeks(getRange(2000_IK, 2020_IK), 5_IK)
39+4, +5, +5, +5, +4, +4, +4, +5, +5, +4, +4, +4, +5, +5, +5, +4, +4, +4, +5, +5, +4
40
41
42getCountWeeks(getRange(2000_IK, 2020_IK), 6_IK)
43+5, +4, +4, +4, +4, +5, +5, +4, +4, +4, +4, +5, +4, +4, +4, +4, +5, +5, +4, +4, +4
44
45
46getCountWeeks(getRange(2000_IK, 2020_IK), 7_IK)
47+4, +4, +4, +5, +5, +4, +4, +4, +5, +5, +5, +4, +4, +4, +5, +5, +4, +4, +4, +4, +5
48
49
50getCountWeeks(getRange(2000_IK, 2020_IK), 8_IK)
51+5, +5, +5, +4, +4, +4, +5, +5, +4, +4, +4, +4, +5, +5, +4, +4, +4, +5, +5, +5, +4
52
53
54getCountWeeks(getRange(2000_IK, 2020_IK), 8_IK)
55+5, +5, +5, +4, +4, +4, +5, +5, +4, +4, +4, +4, +5, +5, +4, +4, +4, +5, +5, +5, +4
56
57
58getCountWeeks(getRange(2000_IK, 2020_IK), 9_IK)
59+4, +4, +4, +4, +5, +5, +4, +4, +4, +4, +5, +5, +4, +4, +4, +4, +5, +4, +4, +4, +4
60
61
62getCountWeeks(getRange(2000_IK, 2020_IK), 10_IK)
63+4, +4, +5, +5, +4, +4, +4, +4, +5, +5, +4, +4, +4, +5, +5, +5, +4, +4, +4, +5, +5
64
65
66getCountWeeks(getRange(2000_IK, 2020_IK), 11_IK)
67+5, +5, +4, +4, +4, +4, +5, +5, +4, +4, +4, +4, +5, +4, +4, +4, +4, +5, +5, +4, +4
68
69
70getCountWeeks(getRange(2000_IK, 2020_IK), 12_IK)
71+4, +4, +4, +4, +5, +5, +4, +4, +4, +5, +5, +5, +4, +4, +4, +5, +5, +4, +4, +4, +5
72
73
74getCountWeeks(2022_IK, getRange(1_IK, 12_IK))
75+4, +4, +5, +4, +4, +5, +4, +4, +5, +4, +4, +5
76
77
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, 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.


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