SUEWS API Site
Documentation of SUEWS source code
Data Types | Functions/Subroutines
mod_timedelta Module Reference

Data Types

interface  timedelta
 

Functions/Subroutines

pure elemental type(timedelta) function timedelta_constructor (days, hours, minutes, seconds, milliseconds)
 
pure elemental integer function getdays (self)
 
pure elemental integer function gethours (self)
 
pure elemental integer function getminutes (self)
 
pure elemental integer function getseconds (self)
 
pure elemental integer function getmilliseconds (self)
 
pure elemental real(kind=real64) function total_seconds (self)
 
pure elemental type(timedelta) function timedelta_plus_timedelta (t0, t1)
 
pure elemental type(timedelta) function timedelta_minus_timedelta (t0, t1)
 
pure elemental type(timedelta) function unary_minus_timedelta (t0)
 
pure elemental logical function eq (td0, td1)
 
pure elemental logical function neq (td0, td1)
 
pure elemental logical function gt (td0, td1)
 
pure elemental logical function ge (td0, td1)
 
pure elemental logical function lt (td0, td1)
 
pure elemental logical function le (td0, td1)
 

Function/Subroutine Documentation

◆ eq()

pure elemental logical function mod_timedelta::eq ( class(timedelta), intent(in)  td0,
type(timedelta), intent(in)  td1 
)
private

Definition at line 359 of file suews_util_datetime.f95.

359 
360  !! `timedelta` object comparison operator. Returns `.true.` if `td0`
361  !! is equal to `td1` and `.false.` otherwise. Overloads the operator
362  !! `==`.
363 
364  class(timedelta), intent(in) :: td0 !! lhs `timedelta` instance
365  type(timedelta), intent(in) :: td1 !! rhs `timedelta` instance
366 
367  eq = td0%total_seconds() == td1%total_seconds()
368 

◆ ge()

pure elemental logical function mod_timedelta::ge ( class(timedelta), intent(in)  td0,
type(timedelta), intent(in)  td1 
)
private

Definition at line 398 of file suews_util_datetime.f95.

398 
399  !! `timedelta` object comparison operator. Returns `.true.` if `td0`
400  !! is greater than or equal to `td1` and `.false.` otherwise.
401  !! Overloads the operator >=.
402 
403  class(timedelta), intent(in) :: td0 !! lhs `timedelta` instance
404  type(timedelta), intent(in) :: td1 !! rhs `timedelta` instance
405 
406  ge = td0%total_seconds() >= td1%total_seconds()
407 

◆ getdays()

pure elemental integer function mod_timedelta::getdays ( class(timedelta), intent(in)  self)
private

Definition at line 268 of file suews_util_datetime.f95.

268  !! Returns the number of days.
269  class(timedelta), intent(in) :: self !! `timedelta` instance
270  getdays = self%days

◆ gethours()

pure elemental integer function mod_timedelta::gethours ( class(timedelta), intent(in)  self)
private

Definition at line 274 of file suews_util_datetime.f95.

274  !! Returns the number of hours.
275  class(timedelta), intent(in) :: self !! `timedelta` instance
276  gethours = self%hours

◆ getmilliseconds()

pure elemental integer function mod_timedelta::getmilliseconds ( class(timedelta), intent(in)  self)
private

Definition at line 292 of file suews_util_datetime.f95.

292  !! Returns the number of milliseconds.
293  class(timedelta), intent(in) :: self !! `timedelta` instance
294  getmilliseconds = self%milliseconds

◆ getminutes()

pure elemental integer function mod_timedelta::getminutes ( class(timedelta), intent(in)  self)
private

Definition at line 280 of file suews_util_datetime.f95.

280  !! Returns the number of minutes.
281  class(timedelta), intent(in) :: self !! `timedelta` instance
282  getminutes = self%minutes

◆ getseconds()

pure elemental integer function mod_timedelta::getseconds ( class(timedelta), intent(in)  self)
private

Definition at line 286 of file suews_util_datetime.f95.

286  !! Returns the number of seconds.
287  class(timedelta), intent(in) :: self !! `timedelta` instance
288  getseconds = self%seconds

◆ gt()

pure elemental logical function mod_timedelta::gt ( class(timedelta), intent(in)  td0,
type(timedelta), intent(in)  td1 
)
private

Definition at line 385 of file suews_util_datetime.f95.

385 
386  !! `timedelta` object comparison operator. Returns `.true.` if
387  !! `td0` is greater than `td1` and `.false.` otherwise. Overloads the
388  !! operator `>`.
389 
390  class(timedelta), intent(in) :: td0 !! lhs `timedelta` instance
391  type(timedelta), intent(in) :: td1 !! rhs `timedelta` instance
392 
393  gt = td0%total_seconds() > td1%total_seconds()
394 

◆ le()

pure elemental logical function mod_timedelta::le ( class(timedelta), intent(in)  td0,
type(timedelta), intent(in)  td1 
)
private

Definition at line 424 of file suews_util_datetime.f95.

424 
425  !! `timedelta` object comparison operator. Returns `.true.` if `td0`
426  !! is less than or equal to `td1` and `.false.` otherwise. Overloads
427  !! the operator `<=`.
428 
429  class(timedelta), intent(in) :: td0 !! lhs `timedelta` instance
430  type(timedelta), intent(in) :: td1 !! rhs `timedelta` instance
431 
432  le = td0%total_seconds() <= td1%total_seconds()
433 

◆ lt()

pure elemental logical function mod_timedelta::lt ( class(timedelta), intent(in)  td0,
type(timedelta), intent(in)  td1 
)
private

Definition at line 411 of file suews_util_datetime.f95.

411 
412  !! `timedelta` object comparison operator. Returns `.true.` if `td0`
413  !! is less than `td1` and `.false.` otherwise. Overloads the operator
414  !! `<`.
415 
416  class(timedelta), intent(in) :: td0 !! lhs `timedelta` instance
417  type(timedelta), intent(in) :: td1 !! rhs `timedelta` instance
418 
419  lt = td0%total_seconds() < td1%total_seconds()
420 

◆ neq()

pure elemental logical function mod_timedelta::neq ( class(timedelta), intent(in)  td0,
type(timedelta), intent(in)  td1 
)
private

Definition at line 372 of file suews_util_datetime.f95.

372 
373  !! `timedelta` object comparison operator. Returns `.true.` if `td0`
374  !! is not equal to `td1` and `.false.` otherwise. Overloads the
375  !! operator `/=`.
376 
377  class(timedelta), intent(in) :: td0 !! lhs `timedelta` instance
378  type(timedelta), intent(in) :: td1 !! rhs `timedelta` instance
379 
380  neq = .not. (td0%total_seconds() == td1%total_seconds())
381 

◆ timedelta_constructor()

pure elemental type(timedelta) function mod_timedelta::timedelta_constructor ( integer, intent(in), optional  days,
integer, intent(in), optional  hours,
integer, intent(in), optional  minutes,
integer, intent(in), optional  seconds,
integer, intent(in), optional  milliseconds 
)
private

Definition at line 223 of file suews_util_datetime.f95.

Referenced by mod_timedelta::timedelta::operator().

223 
224  !! Constructor function for the `timedelta` class.
225 
226  integer, intent(in), optional :: days !! number of days
227  integer, intent(in), optional :: hours !! number of hours
228  integer, intent(in), optional :: minutes !! number of minutes
229  integer, intent(in), optional :: seconds !! number of seconds
230  integer, intent(in), optional :: milliseconds !! number of milliseconds
231 
232  if (present(days)) then
233  timedelta_constructor%days = days
234  else
235  timedelta_constructor%days = 0
236  endif
237 
238  if (present(hours)) then
239  timedelta_constructor%hours = hours
240  else
241  timedelta_constructor%hours = 0
242  endif
243 
244  if (present(minutes)) then
245  timedelta_constructor%minutes = minutes
246  else
247  timedelta_constructor%minutes = 0
248  endif
249 
250  if (present(seconds)) then
251  timedelta_constructor%seconds = seconds
252  else
253  timedelta_constructor%seconds = 0
254  endif
255 
256  if (present(milliseconds)) then
257  timedelta_constructor%milliseconds = milliseconds
258  else
259  timedelta_constructor%milliseconds = 0
260  endif
261 
Here is the caller graph for this function:

◆ timedelta_minus_timedelta()

pure elemental type(timedelta) function mod_timedelta::timedelta_minus_timedelta ( class(timedelta), intent(in)  t0,
type(timedelta), intent(in)  t1 
)
private

Definition at line 330 of file suews_util_datetime.f95.

330 
331  !! Subtracts a `timedelta` instance from another. Returns a
332  !! `timedelta` instance. Overloads the operator `-`.
333 
334  class(timedelta), intent(in) :: t0 !! lhs `timedelta` instance
335  type(timedelta), intent(in) :: t1 !! lhs `timedelta` instance
336  type(timedelta) :: t !! result
337 
338  t = t0 + (-t1)
339 

◆ timedelta_plus_timedelta()

pure elemental type(timedelta) function mod_timedelta::timedelta_plus_timedelta ( class(timedelta), intent(in)  t0,
type(timedelta), intent(in)  t1 
)
private

Definition at line 313 of file suews_util_datetime.f95.

313 
314  !! Adds two `timedelta` instances together and returns a `timedelta`
315  !! instance. Overloads the operator `+`.
316 
317  class(timedelta), intent(in) :: t0 !! lhs `timedelta` instance
318  type(timedelta), intent(in) :: t1 !! rhs `timedelta` instance
319  type(timedelta) :: t !! result
320 
321  t = timedelta(days=t0%days + t1%days, &
322  hours=t0%hours + t1%hours, &
323  minutes=t0%minutes + t1%minutes, &
324  seconds=t0%seconds + t1%seconds, &
325  milliseconds=t0%milliseconds + t1%milliseconds)
326 

◆ total_seconds()

pure elemental real(kind=real64) function mod_timedelta::total_seconds ( class(timedelta), intent(in)  self)
private

Definition at line 298 of file suews_util_datetime.f95.

298 
299  !! Returns a total number of seconds contained in a `timedelta`
300  !! instance.
301 
302  class(timedelta), intent(in) :: self !! `timedelta` instance
303 
304  total_seconds = self%days*86400._real64 &
305  + self%hours*3600._real64 &
306  + self%minutes*60._real64 &
307  + self%seconds &
308  + self%milliseconds*1e-3_real64
309 

◆ unary_minus_timedelta()

pure elemental type(timedelta) function mod_timedelta::unary_minus_timedelta ( class(timedelta), intent(in)  t0)
private

Definition at line 343 of file suews_util_datetime.f95.

343 
344  !! Takes a negative of a `timedelta` instance. Overloads the operator
345  !! `-`.
346 
347  class(timedelta), intent(in) :: t0 !! `timedelta` instance
348  type(timedelta) :: t !! result
349 
350  t%days = -t0%days
351  t%hours = -t0%hours
352  t%minutes = -t0%minutes
353  t%seconds = -t0%seconds
354  t%milliseconds = -t0%milliseconds
355