gtool5 Fortran 90/95 ライブラリ 1.0.0-rc5
English
Loading...
Searching...
No Matches
dcdatetimelt.f90
Go to the documentation of this file.
1! -*- mode: f90; coding: utf-8 -*-
2!-----------------------------------------------------------------------
3! Copyright (c) 2000-2026 Gtool Development Group. All rights reserved.
4!-----------------------------------------------------------------------
5!>
6!> @author Yasuhiro MORIKAWA
7!> @copyright Copyright (C) GFD Dennou Club, 2000-2026. All rights reserved. <br/>
8!> License is BSD-2-Clause. see [COPYRIGHT](@ref COPYRIGHT) in detail
9!> @en
10!> @brief Functions for user defined operation (<)
11!> @details
12!> This file contains implementation procedures of less-than
13!> comparison for dc_date_types#DC_DATETIME and dc_date_types#DC_DIFFTIME.
14!> @enden
15!>
16!> @ja
17!> @brief 利用者定義演算子 (<) のための関数
18!> @details
19!> このファイルには dc_date_types#DC_DATETIME および dc_date_types#DC_DIFFTIME
20!> の小なり比較の実装手続きが含まれています。
21!> @endja
22!>
23
24!> @en
25!> @brief Compare two DC_DATETIME variables (<)
26!> @details
27!> Compare two datetime values.
28!> Returns .true. if the datetime stored in the second argument is
29!> later than the datetime stored in the first argument.
30!>
31!> @param[in] time1 First datetime to compare
32!> @param[in] time2 Second datetime to compare
33!> @return .true. if time1 < time2, .false. otherwise
34!> @enden
35!>
36!> @ja
37!> @brief 2つの DC_DATETIME 変数の比較 (<)
38!> @details
39!> 2 つの引数の日時を比較します.
40!> 2 つ目の引数に格納される日時が 1 つ目の引数に格納される日時
41!> よりも進んでいる場合, .true. が返ります.
42!>
43!> @param[in] time1 比較する1番目の日時
44!> @param[in] time2 比較する2番目の日時
45!> @return time1 < time2 の場合 .true., それ以外は .false.
46!> @endja
47logical function dcdatetime_lt_tt(time1, time2) result(result)
48
51 use dc_scaledsec, only: dc_scaled_sec, &
52 & operator(==), operator(<), operator(>), operator(<=), operator(>=), &
53 & operator(+)
54 implicit none
55 type(dc_datetime), intent(in):: time1, time2
56 type(dc_scaled_sec):: year1, year2, time1_sec, time2_sec
57continue
58 call eval(time1, sclyear=year1)
59 call eval(time2, sclyear=year2)
60 if (year1 < year2) then
61 result = .true.
62 elseif (year1 > year2) then
63 result = .false.
64 else
65 time1_sec = evalsclsec(time1) + evalsclsec(zonetodiff(time1 % zone))
66 time2_sec = evalsclsec(time2) + evalsclsec(zonetodiff(time2 % zone))
67 if (time1_sec < time2_sec) then
68 result = .true.
69 else
70 result = .false.
71 end if
72 end if
73end function dcdatetime_lt_tt
74
75!> @en
76!> @brief Compare two DC_DIFFTIME variables (<)
77!> @details
78!> Compare two time difference values.
79!> Returns .true. if the time difference stored in the second argument is
80!> greater than the time difference stored in the first argument.
81!>
82!> @param[in] diff1 First time difference to compare
83!> @param[in] diff2 Second time difference to compare
84!> @return .true. if diff1 < diff2, .false. otherwise
85!> @enden
86!>
87!> @ja
88!> @brief 2つの DC_DIFFTIME 変数の比較 (<)
89!> @details
90!> 2 つの引数の日時差を比較します.
91!> 2 つ目の引数に格納される日時差が 1 つ目の引数に格納される日時差
92!> よりも大きい場合, .true. が返ります.
93!>
94!> @param[in] diff1 比較する1番目の日時差
95!> @param[in] diff2 比較する2番目の日時差
96!> @return diff1 < diff2 の場合 .true., それ以外は .false.
97!> @endja
98logical function dcdatetime_lt_ff(diff1, diff2) result(result)
99
100 use dc_date_generic, only: evalsec
102 use dc_scaledsec, only: &
103 & operator(<), operator(>), operator(<=), operator(>=), operator(==)
104 implicit none
105 type(dc_difftime), intent(in):: diff1, diff2
106continue
107 if ( diff1 % day_seconds == diff2 % day_seconds ) then
108
109 if ( diff1 % mon < diff2 % mon ) then
110 result = .true. ; return
111 elseif ( diff1 % mon > diff2 % mon ) then
112 result = .false. ; return
113 end if
114 if ( diff1 % day < diff2 % day ) then
115 result = .true. ; return
116 elseif ( diff1 % day > diff2 % day ) then
117 result = .false. ; return
118 end if
119 if ( diff1 % sec < diff2 % sec ) then
120 result = .true. ; return
121 elseif ( diff1 % sec > diff2 % sec ) then
122 result = .false. ; return
123 end if
124 result = .false.
125 else
126
127 if (evalsec(diff1) < evalsec(diff2)) then
128 result = .true.
129 else
130 result = .false.
131 end if
132 end if
133
134end function dcdatetime_lt_ff
135
136!> @en
137!> @brief Compare DC_DIFFTIME with integer (<)
138!> @details
139!> Compare a time difference value with an integer.
140!> Returns .true. if the time difference stored in the first argument is
141!> less than the integer stored in the second argument.
142!>
143!> @param[in] diff Time difference to compare
144!> @param[in] factor Integer value to compare
145!> @return .true. if diff < factor, .false. otherwise
146!> @enden
147!>
148!> @ja
149!> @brief DC_DIFFTIME と整数の比較 (<)
150!> @details
151!> 2 つの引数の日時差を比較します.
152!> 2 つ目の引数に格納される日時差が 1 つ目の引数に格納される日時差
153!> よりも大きい場合, .true. が返ります.
154!>
155!> @param[in] diff 比較する日時差
156!> @param[in] factor 比較する整数値
157!> @return diff < factor の場合 .true., それ以外は .false.
158!> @endja
159logical function dcdatetime_lt_fi(diff, factor) result(result)
160
161 use dc_date_generic, only: evalsec
163 implicit none
164 type(dc_difftime), intent(in):: diff
165 integer, intent(in):: factor
166continue
167 result = evalsec(diff) < factor
168end function dcdatetime_lt_fi
169
170!> @en
171!> @brief Compare integer with DC_DIFFTIME (<)
172!> @details
173!> Compare an integer with a time difference value.
174!> Returns .true. if the integer stored in the first argument is
175!> less than the time difference stored in the second argument.
176!>
177!> @param[in] factor Integer value to compare
178!> @param[in] diff Time difference to compare
179!> @return .true. if factor < diff, .false. otherwise
180!> @enden
181!>
182!> @ja
183!> @brief 整数と DC_DIFFTIME の比較 (<)
184!> @details
185!> 2 つの引数の日時差を比較します.
186!> 2 つ目の引数に格納される日時差が 1 つ目の引数に格納される日時差
187!> よりも大きい場合, .true. が返ります.
188!>
189!> @param[in] factor 比較する整数値
190!> @param[in] diff 比較する日時差
191!> @return factor < diff の場合 .true., それ以外は .false.
192!> @endja
193logical function dcdatetime_lt_if(factor, diff) result(result)
194
195 use dc_date_generic, only: evalsec
197 implicit none
198 integer, intent(in):: factor
199 type(dc_difftime), intent(in):: diff
200continue
201 result = factor < evalsec(diff)
202end function dcdatetime_lt_if
logical function dcdatetime_lt_ff(diff1, diff2)
logical function dcdatetime_lt_if(factor, diff)
logical function dcdatetime_lt_fi(diff, factor)
logical function dcdatetime_lt_tt(time1, time2)
利用者定義演算子 (<) のための関数
dc_date より提供される手続の引用仕様宣言
日付・時刻に関する構造データ型と定数
精密な時間演算のための秒スケールモジュール