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

Data Types

interface  datetime
 

Functions/Subroutines

pure elemental type(datetime) function datetime_constructor (year, month, day, hour, minute, second, millisecond, tz)
 
pure elemental integer function getyear (self)
 
pure elemental integer function getmonth (self)
 
pure elemental integer function getday (self)
 
pure elemental integer function gethour (self)
 
pure elemental integer function getminute (self)
 
pure elemental integer function getsecond (self)
 
pure elemental integer function getmillisecond (self)
 
pure elemental real(kind=real64) function gettz (self)
 
pure elemental subroutine addmilliseconds (self, ms)
 
pure elemental subroutine addseconds (self, s)
 
pure elemental subroutine addminutes (self, m)
 
pure elemental subroutine addhours (self, h)
 
pure elemental subroutine adddays (self, d)
 
pure elemental character(len=23) function isoformat (self, sep)
 
pure elemental logical function isvalid (self)
 
type(datetime) function now ()
 
pure elemental integer function weekday (self)
 
pure elemental integer function isoweekday (self)
 
pure elemental character(len=9) function weekdaylong (self)
 
pure elemental character(len=9) function isoweekdaylong (self)
 
pure elemental character(len=3) function weekdayshort (self)
 
pure elemental character(len=3) function isoweekdayshort (self)
 
integer function, dimension(3) isocalendar (self)
 
integer function secondssinceepoch (self)
 
character(len=:) function, allocatable strftime (self, format)
 
pure elemental type(tm_struct) function tm (self)
 
pure elemental character(len=5) function tzoffset (self)
 
pure elemental type(datetime) function utc (self)
 
pure elemental integer function yearday (self)
 
pure elemental type(datetime) function datetime_plus_timedelta (d0, t)
 
pure elemental type(datetime) function timedelta_plus_datetime (t, d0)
 
pure elemental type(datetime) function datetime_minus_timedelta (d0, t)
 
pure elemental type(timedelta) function datetime_minus_datetime (d0, d1)
 
pure elemental logical function gt (d0, d1)
 
pure elemental logical function lt (d0, d1)
 
pure elemental logical function eq (d0, d1)
 
pure elemental logical function neq (d0, d1)
 
pure elemental logical function ge (d0, d1)
 
pure elemental logical function le (d0, d1)
 
pure elemental logical function, public isleapyear (year)
 
pure type(datetime) function, dimension(:), allocatable, public datetimerange (d0, d1, t)
 
pure elemental integer function, public daysinmonth (month, year)
 
pure elemental integer function, public daysinyear (year)
 
pure elemental real(kind=real64) function, public date2num (d)
 
pure elemental type(datetime) function, public num2date (num)
 
type(datetime) function, public strptime (str, format)
 
pure elemental type(datetime) function, public tm2date (ctime)
 
pure character(len=length) function int2str (i, length)
 

Function/Subroutine Documentation

◆ adddays()

pure elemental subroutine mod_datetime::adddays ( class(datetime), intent(inout) self,
integer, intent(in) d )
private

Definition at line 774 of file suews_util_datetime.f95.

775
776 !! Adds an integer number of dayss to self. Called by `datetime`
777 !! addition (`+`) and subtraction (`-`) operators.
778
779 CLASS(datetime), INTENT(inout) :: self !! `datetime` instance
780 INTEGER, INTENT(in) :: d !! number of days to add
781
782 INTEGER :: daysInCurrentMonth
783
784 self%day = self%day + d
785 DO
786 daysincurrentmonth = daysinmonth(self%month, self%year)
787 IF (self%day > daysincurrentmonth) THEN
788 self%day = self%day - daysincurrentmonth
789 self%month = self%month + 1
790 IF (self%month > 12) THEN
791 self%year = self%year + self%month/12
792 self%month = mod(self%month, 12)
793 END IF
794 ELSEIF (self%day < 1) THEN
795 self%month = self%month - 1
796 IF (self%month < 1) THEN
797 self%year = self%year + self%month/12 - 1
798 self%month = 12 + mod(self%month, 12)
799 END IF
800 self%day = self%day + daysinmonth(self%month, self%year)
801 ELSE
802 EXIT
803 END IF
804 END DO
805

References daysinmonth().

Here is the call graph for this function:

◆ addhours()

pure elemental subroutine mod_datetime::addhours ( class(datetime), intent(inout) self,
integer, intent(in) h )
private

Definition at line 750 of file suews_util_datetime.f95.

751
752 !! Adds an integer number of hours to self. Called by `datetime`
753 !! addition (`+`) and subtraction (`-`) operators.
754
755 CLASS(datetime), INTENT(inout) :: self !! `datetime` instance
756 INTEGER, INTENT(in) :: h !! number of hours to add
757
758 self%hour = self%hour + h
759
760 DO
761 IF (self%hour >= 24) THEN
762 CALL self%addDays(self%hour/24)
763 self%hour = mod(self%hour, 24)
764 ELSEIF (self%hour < 0) THEN
765 CALL self%addDays(self%hour/24 - 1)
766 self%hour = mod(self%hour, 24) + 24
767 ELSE
768 EXIT
769 END IF
770 END DO
771

◆ addmilliseconds()

pure elemental subroutine mod_datetime::addmilliseconds ( class(datetime), intent(inout) self,
integer, intent(in) ms )
private

Definition at line 675 of file suews_util_datetime.f95.

676
677 !! Adds an integer number of milliseconds to self. Called by `datetime`
678 !! addition (`+`) and subtraction (`-`) operators.
679
680 CLASS(datetime), INTENT(inout) :: self !! `datetime` instance
681 INTEGER, INTENT(in) :: ms !! number of milliseconds to add
682
683 self%millisecond = self%millisecond + ms
684
685 DO
686 IF (self%millisecond >= 1000) THEN
687 CALL self%addSeconds(self%millisecond/1000)
688 self%millisecond = mod(self%millisecond, 1000)
689 ELSEIF (self%millisecond < 0) THEN
690 CALL self%addSeconds(self%millisecond/1000 - 1)
691 self%millisecond = mod(self%millisecond, 1000) + 1000
692 ELSE
693 EXIT
694 END IF
695 END DO
696

◆ addminutes()

pure elemental subroutine mod_datetime::addminutes ( class(datetime), intent(inout) self,
integer, intent(in) m )
private

Definition at line 726 of file suews_util_datetime.f95.

727
728 !! Adds an integer number of minutes to self. Called by `datetime`
729 !! addition (`+`) and subtraction (`-`) operators.
730
731 CLASS(datetime), INTENT(inout) :: self !! `datetime` instance
732 INTEGER, INTENT(in) :: m !! number of minutes to add
733
734 self%minute = self%minute + m
735
736 DO
737 IF (self%minute >= 60) THEN
738 CALL self%addHours(self%minute/60)
739 self%minute = mod(self%minute, 60)
740 ELSEIF (self%minute < 0) THEN
741 CALL self%addHours(self%minute/60 - 1)
742 self%minute = mod(self%minute, 60) + 60
743 ELSE
744 EXIT
745 END IF
746 END DO
747

◆ addseconds()

pure elemental subroutine mod_datetime::addseconds ( class(datetime), intent(inout) self,
integer, intent(in) s )
private

Definition at line 702 of file suews_util_datetime.f95.

703
704 !! Adds an integer number of seconds to self. Called by `datetime`
705 !! addition (`+`) and subtraction (`-`) operators.
706
707 CLASS(datetime), INTENT(inout) :: self !! `datetime` instance
708 INTEGER, INTENT(in) :: s !! number of seconds to add
709
710 self%second = self%second + s
711
712 DO
713 IF (self%second >= 60) THEN
714 CALL self%addMinutes(self%second/60)
715 self%second = mod(self%second, 60)
716 ELSEIF (self%second < 0) THEN
717 CALL self%addMinutes(self%second/60 - 1)
718 self%second = mod(self%second, 60) + 60
719 ELSE
720 EXIT
721 END IF
722 END DO
723

◆ date2num()

pure elemental real(kind=real64) function, public mod_datetime::date2num ( type(datetime), intent(in) d)

Definition at line 1504 of file suews_util_datetime.f95.

1505
1506 !! Given a datetime instance d, returns number of days since
1507 !! `0001-01-01 00:00:00`, taking into account the timezone offset.
1508
1509 TYPE(datetime), INTENT(in) :: d !! `datetime` instance
1510
1511 TYPE(datetime) :: d_utc
1512 INTEGER :: year
1513
1514 ! Convert to UTC first
1515 d_utc = d%utc()
1516
1517 ! d_utc % year must be positive:
1518 IF (d_utc%year < 1) THEN
1519 date2num = 0
1520 RETURN
1521 END IF
1522
1523 date2num = 0
1524 DO year = 1, d_utc%year - 1
1525 date2num = date2num + daysinyear(year)
1526 END DO
1527
1528 date2num = date2num &
1529 + d_utc%yearday() &
1530 + d_utc%hour*h2d &
1531 + d_utc%minute*m2d &
1532 + (d_utc%second + 1e-3_real64*d_utc%millisecond)*s2d
1533

References date2num(), and daysinyear().

Referenced by date2num(), datetime_minus_datetime(), and datetimerange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ datetime_constructor()

pure elemental type(datetime) function mod_datetime::datetime_constructor ( integer, intent(in), optional year,
integer, intent(in), optional month,
integer, intent(in), optional day,
integer, intent(in), optional hour,
integer, intent(in), optional minute,
integer, intent(in), optional second,
integer, intent(in), optional millisecond,
real(kind=real64), intent(in), optional tz )
private

Definition at line 560 of file suews_util_datetime.f95.

562
563 !! Constructor function for the `datetime` class.
564
565 INTEGER, INTENT(in), OPTIONAL :: year !! year
566 INTEGER, INTENT(in), OPTIONAL :: month !! month
567 INTEGER, INTENT(in), OPTIONAL :: day !! day
568 INTEGER, INTENT(in), OPTIONAL :: hour !! hour
569 INTEGER, INTENT(in), OPTIONAL :: minute !! minute
570 INTEGER, INTENT(in), OPTIONAL :: second !! second
571 INTEGER, INTENT(in), OPTIONAL :: millisecond !! millisecond
572 REAL(kind=real64), INTENT(in), OPTIONAL :: tz !! timezone offset in hours
573
574 IF (PRESENT(year)) THEN
575 datetime_constructor%year = year
576 ELSE
577 datetime_constructor%year = 1
578 END IF
579
580 IF (PRESENT(month)) THEN
581 datetime_constructor%month = month
582 ELSE
583 datetime_constructor%month = 1
584 END IF
585
586 IF (PRESENT(day)) THEN
587 datetime_constructor%day = day
588 ELSE
589 datetime_constructor%day = 1
590 END IF
591
592 IF (PRESENT(hour)) THEN
593 datetime_constructor%hour = hour
594 ELSE
595 datetime_constructor%hour = 0
596 END IF
597
598 IF (PRESENT(minute)) THEN
599 datetime_constructor%minute = minute
600 ELSE
601 datetime_constructor%minute = 0
602 END IF
603
604 IF (PRESENT(second)) THEN
605 datetime_constructor%second = second
606 ELSE
607 datetime_constructor%second = 0
608 END IF
609
610 IF (PRESENT(millisecond)) THEN
611 datetime_constructor%millisecond = millisecond
612 ELSE
613 datetime_constructor%millisecond = 0
614 END IF
615
616 IF (PRESENT(tz)) THEN
617 datetime_constructor%tz = tz
618 ELSE
619 datetime_constructor%tz = 0
620 END IF
621

Referenced by mod_datetime::datetime::datetime_constructor(), and mod_datetime::datetime::operator().

Here is the caller graph for this function:

◆ datetime_minus_datetime()

pure elemental type(timedelta) function mod_datetime::datetime_minus_datetime ( class(datetime), intent(in) d0,
class(datetime), intent(in) d1 )
private

Definition at line 1233 of file suews_util_datetime.f95.

1234
1235 !! Subtracts a `datetime` instance from another `datetime` instance,
1236 !! and returns a `timedelta` instance. Overloads the operator `-`.
1237
1238 CLASS(datetime), INTENT(in) :: d0 !! lhs `datetime` instance
1239 CLASS(datetime), INTENT(in) :: d1 !! rhs `datetime` instance
1240 TYPE(timedelta) :: t
1241
1242 REAL(kind=real64) :: daysdiff
1243 INTEGER :: days, hours, minutes, seconds, milliseconds
1244 INTEGER :: sign_
1245
1246 daysdiff = date2num(d0) - date2num(d1)
1247
1248 IF (daysdiff < 0) THEN
1249 sign_ = -1
1250 daysdiff = abs(daysdiff)
1251 ELSE
1252 sign_ = 1
1253 END IF
1254
1255 days = int(daysdiff)
1256 hours = int((daysdiff - days)*d2h)
1257 minutes = int((daysdiff - days - hours*h2d)*d2m)
1258 seconds = int((daysdiff - days - hours*h2d - minutes*m2d)*d2s)
1259 milliseconds = nint((daysdiff - days - hours*h2d - minutes*m2d &
1260 - seconds*s2d)*d2s*1e3_real64)
1261
1262 t = timedelta(sign_*days, sign_*hours, sign_*minutes, sign_*seconds, &
1263 sign_*milliseconds)
1264

References date2num().

Referenced by mod_datetime::datetime::operator().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ datetime_minus_timedelta()

pure elemental type(datetime) function mod_datetime::datetime_minus_timedelta ( class(datetime), intent(in) d0,
class(timedelta), intent(in) t )
private

Definition at line 1220 of file suews_util_datetime.f95.

1221
1222 !! Subtracts a `timedelta` instance from a `datetime` instance and
1223 !! returns a new `datetime` instance. Overloads the operator `-`.
1224
1225 CLASS(datetime), INTENT(in) :: d0 !! `datetime` instance
1226 CLASS(timedelta), INTENT(in) :: t !! `timedelta` instance
1227 TYPE(datetime) :: d
1228
1229 d = d0 + (-t)
1230

Referenced by mod_datetime::datetime::operator().

Here is the caller graph for this function:

◆ datetime_plus_timedelta()

pure elemental type(datetime) function mod_datetime::datetime_plus_timedelta ( class(datetime), intent(in) d0,
class(timedelta), intent(in) t )
private

Definition at line 1173 of file suews_util_datetime.f95.

1174
1175 !! Adds a `timedelta` instance to a `datetime` instance, and returns a
1176 !! new `datetime` instance. Overloads the operator `+`.
1177
1178 CLASS(datetime), INTENT(in) :: d0 !! `datetime` instance
1179 CLASS(timedelta), INTENT(in) :: t !! `timedelta` instance
1180 TYPE(datetime) :: d
1181
1182 INTEGER :: milliseconds, seconds, minutes, hours, days
1183
1184 d = datetime(year=d0%getYear(), &
1185 month=d0%getMonth(), &
1186 day=d0%getDay(), &
1187 hour=d0%getHour(), &
1188 minute=d0%getMinute(), &
1189 second=d0%getSecond(), &
1190 millisecond=d0%getMillisecond(), &
1191 tz=d0%getTz())
1192
1193 milliseconds = t%getMilliseconds()
1194 seconds = t%getSeconds()
1195 minutes = t%getMinutes()
1196 hours = t%getHours()
1197 days = t%getDays()
1198
1199 IF (milliseconds /= 0) CALL d%addMilliseconds(milliseconds)
1200 IF (seconds /= 0) CALL d%addSeconds(seconds)
1201 IF (minutes /= 0) CALL d%addMinutes(minutes)
1202 IF (hours /= 0) CALL d%addHours(hours)
1203 IF (days /= 0) CALL d%addDays(days)
1204

Referenced by mod_datetime::datetime::operator().

Here is the caller graph for this function:

◆ datetimerange()

pure type(datetime) function, dimension(:), allocatable, public mod_datetime::datetimerange ( type(datetime), intent(in) d0,
type(datetime), intent(in) d1,
type(timedelta), intent(in) t )

Definition at line 1428 of file suews_util_datetime.f95.

1429
1430 !! Given start and end `datetime` instances `d0` and `d1` and time
1431 !! increment as `timedelta` instance `t`, returns an array of
1432 !! `datetime` instances. The number of elements is the number of whole
1433 !! time increments contained between datetimes `d0` and `d1`.
1434
1435 TYPE(datetime), INTENT(in) :: d0 !! start time
1436 TYPE(datetime), INTENT(in) :: d1 !! end time
1437 TYPE(timedelta), INTENT(in) :: t !! time increment
1438
1439 REAL(kind=real64) :: datenum0, datenum1, increment
1440 REAL(kind=real64) :: eps
1441
1442 TYPE(datetime), DIMENSION(:), ALLOCATABLE :: datetimeRange
1443
1444 INTEGER :: n, nm
1445
1446 eps = 1e-10_real64
1447
1448 datenum0 = date2num(d0)
1449 datenum1 = date2num(d1)
1450
1451 increment = t%total_seconds()*s2d
1452
1453 nm = floor((datenum1 - datenum0 + eps)/increment) + 1
1454
1455 ALLOCATE (datetimerange(nm))
1456
1457 DO n = 1, nm
1458 datetimerange(n) = num2date(datenum0 + (n - 1)*increment)
1459 END DO
1460

References date2num(), datetimerange(), and num2date().

Referenced by datetimerange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ daysinmonth()

pure elemental integer function, public mod_datetime::daysinmonth ( integer, intent(in) month,
integer, intent(in) year )

Definition at line 1463 of file suews_util_datetime.f95.

1464
1465 !! Given integer month and year, returns an integer number
1466 !! of days in that particular month.
1467
1468 INTEGER, INTENT(in) :: month !! month
1469 INTEGER, INTENT(in) :: year !! year
1470
1471 INTEGER, PARAMETER, DIMENSION(12) :: &
1472 days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
1473
1474 IF (month < 1 .OR. month > 12) THEN
1475 ! Should raise an error and abort here, however we want to keep
1476 ! the pure and elemental attributes. Make sure this function is
1477 ! called with the month argument in range.
1478 daysinmonth = 0
1479 RETURN
1480 END IF
1481
1482 IF (month == 2 .AND. isleapyear(year)) THEN
1483 daysinmonth = 29
1484 ELSE
1485 daysinmonth = days(month)
1486 END IF
1487

References daysinmonth(), and isleapyear().

Referenced by adddays(), daysinmonth(), isvalid(), num2date(), and yearday().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ daysinyear()

pure elemental integer function, public mod_datetime::daysinyear ( integer, intent(in) year)

Definition at line 1490 of file suews_util_datetime.f95.

1491
1492 !! Returns the number of days in year.
1493
1494 INTEGER, INTENT(in) :: year !! year
1495
1496 IF (isleapyear(year)) THEN
1497 daysinyear = 366
1498 ELSE
1499 daysinyear = 365
1500 END IF
1501

References daysinyear(), and isleapyear().

Referenced by date2num(), daysinyear(), and num2date().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eq()

pure elemental logical function mod_datetime::eq ( class(datetime), intent(in) d0,
class(datetime), intent(in) d1 )
private

Definition at line 1352 of file suews_util_datetime.f95.

1353
1354 !! `datetime` comparison operator that returns `.true.` if `d0` is
1355 !! equal to `d1` and `.false.` otherwise. Overloads the operator `==`.
1356
1357 CLASS(datetime), INTENT(in) :: d0 !! lhs `datetime` instance
1358 CLASS(datetime), INTENT(in) :: d1 !! rhs `datetime` instance
1359
1360 TYPE(datetime) :: d0_utc, d1_utc
1361
1362 ! Convert to UTC before making comparison
1363 d0_utc = d0%utc()
1364 d1_utc = d1%utc()
1365
1366 eq = d0_utc%year == d1_utc%year .AND. &
1367 d0_utc%month == d1_utc%month .AND. &
1368 d0_utc%day == d1_utc%day .AND. &
1369 d0_utc%hour == d1_utc%hour .AND. &
1370 d0_utc%minute == d1_utc%minute .AND. &
1371 d0_utc%second == d1_utc%second .AND. &
1372 d0_utc%millisecond == d1_utc%millisecond
1373

References eq().

Referenced by eq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ge()

pure elemental logical function mod_datetime::ge ( class(datetime), intent(in) d0,
class(datetime), intent(in) d1 )
private

Definition at line 1388 of file suews_util_datetime.f95.

1389
1390 !! `datetime` comparison operator. Returns `.true.` if `d0` is greater
1391 !! than or equal to `d1` and `.false.` otherwise. Overloads the
1392 !! operator `>=`.
1393
1394 CLASS(datetime), INTENT(in) :: d0 !! lhs `datetime` instance
1395 CLASS(datetime), INTENT(in) :: d1 !! rhs `datetime` instance
1396
1397 ge = d0 > d1 .OR. d0 == d1
1398

References ge().

Referenced by ge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getday()

pure elemental integer function mod_datetime::getday ( class(datetime), intent(in) self)
private

Definition at line 639 of file suews_util_datetime.f95.

640 !! Returns the year component
641 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
642 getday = self%day

References getday().

Referenced by getday().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gethour()

pure elemental integer function mod_datetime::gethour ( class(datetime), intent(in) self)
private

Definition at line 645 of file suews_util_datetime.f95.

646 !! Returns the year component
647 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
648 gethour = self%hour

References gethour().

Referenced by gethour().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getmillisecond()

pure elemental integer function mod_datetime::getmillisecond ( class(datetime), intent(in) self)
private

Definition at line 663 of file suews_util_datetime.f95.

664 !! Returns the year component
665 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
666 getmillisecond = self%millisecond

References getmillisecond().

Referenced by getmillisecond().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getminute()

pure elemental integer function mod_datetime::getminute ( class(datetime), intent(in) self)
private

Definition at line 651 of file suews_util_datetime.f95.

652 !! Returns the year component
653 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
654 getminute = self%minute

References getminute().

Referenced by getminute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getmonth()

pure elemental integer function mod_datetime::getmonth ( class(datetime), intent(in) self)
private

Definition at line 633 of file suews_util_datetime.f95.

634 !! Returns the year component
635 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
636 getmonth = self%month

References getmonth().

Referenced by getmonth().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getsecond()

pure elemental integer function mod_datetime::getsecond ( class(datetime), intent(in) self)
private

Definition at line 657 of file suews_util_datetime.f95.

658 !! Returns the year component
659 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
660 getsecond = self%second

References getsecond().

Referenced by getsecond().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gettz()

pure elemental real(kind=real64) function mod_datetime::gettz ( class(datetime), intent(in) self)
private

Definition at line 669 of file suews_util_datetime.f95.

670 !! Returns the timezone offset component
671 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
672 gettz = self%tz

References gettz().

Referenced by gettz().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getyear()

pure elemental integer function mod_datetime::getyear ( class(datetime), intent(in) self)
private

Definition at line 627 of file suews_util_datetime.f95.

628 !! Returns the year component
629 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
630 getyear = self%year

References getyear().

Referenced by getyear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gt()

pure elemental logical function mod_datetime::gt ( class(datetime), intent(in) d0,
class(datetime), intent(in) d1 )
private

Definition at line 1267 of file suews_util_datetime.f95.

1268
1269 !! `datetime` comparison operator that eturns `.true.` if `d0` is
1270 !! greater than `d1` and `.false.` otherwise. Overloads the
1271 !! operator `>`.
1272
1273 CLASS(datetime), INTENT(in) :: d0 !! lhs `datetime` instance
1274 CLASS(datetime), INTENT(in) :: d1 !! rhs `datetime` instance
1275
1276 TYPE(datetime) :: d0_utc, d1_utc
1277
1278 ! Convert to UTC before making comparison
1279 d0_utc = d0%utc()
1280 d1_utc = d1%utc()
1281
1282 ! Year comparison block
1283 IF (d0_utc%year > d1_utc%year) THEN
1284 gt = .true.
1285 ELSEIF (d0_utc%year < d1_utc%year) THEN
1286 gt = .false.
1287 ELSE
1288
1289 ! Month comparison block
1290 IF (d0_utc%month > d1_utc%month) THEN
1291 gt = .true.
1292 ELSEIF (d0_utc%month < d1_utc%month) THEN
1293 gt = .false.
1294 ELSE
1295
1296 ! Day comparison block
1297 IF (d0_utc%day > d1_utc%day) THEN
1298 gt = .true.
1299 ELSEIF (d0_utc%day < d1_utc%day) THEN
1300 gt = .false.
1301 ELSE
1302
1303 ! Hour comparison block
1304 IF (d0_utc%hour > d1_utc%hour) THEN
1305 gt = .true.
1306 ELSEIF (d0_utc%hour < d1_utc%hour) THEN
1307 gt = .false.
1308 ELSE
1309
1310 ! Minute comparison block
1311 IF (d0_utc%minute > d1_utc%minute) THEN
1312 gt = .true.
1313 ELSEIF (d0_utc%minute < d1_utc%minute) THEN
1314 gt = .false.
1315 ELSE
1316
1317 ! Second comparison block
1318 IF (d0_utc%second > d1_utc%second) THEN
1319 gt = .true.
1320 ELSEIF (d0_utc%second < d1_utc%second) THEN
1321 gt = .false.
1322 ELSE
1323
1324 ! Millisecond comparison block
1325 IF (d0_utc%millisecond > d1_utc%millisecond) THEN
1326 gt = .true.
1327 ELSE
1328 gt = .false.
1329 END IF
1330
1331 END IF
1332 END IF
1333 END IF
1334 END IF
1335 END IF
1336 END IF
1337

References gt().

Referenced by gt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ int2str()

pure character(len=length) function mod_datetime::int2str ( integer, intent(in) i,
integer, intent(in) length )
private

Definition at line 1636 of file suews_util_datetime.f95.

1637
1638 !! Converts an integer `i` into a character string of requested length,
1639 !! pre-pending zeros if necessary.
1640
1641 INTEGER, INTENT(in) :: i !! integer to convert to string
1642 INTEGER, INTENT(in) :: length !! desired length of string
1643
1644 CHARACTER(len=length) :: int2str
1645 CHARACTER(len=2) :: string
1646
1647 WRITE (unit=string, fmt='(I2)') length
1648 WRITE (unit=int2str, fmt='(I'//string//'.'//string//')') i
1649

References int2str().

Referenced by int2str(), and isoformat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isleapyear()

pure elemental logical function, public mod_datetime::isleapyear ( integer, intent(in) year)

Definition at line 1417 of file suews_util_datetime.f95.

1418
1419 !! Returns `.true.` if year is leap year and `.false.` otherwise.
1420
1421 INTEGER, INTENT(in) :: year !! year
1422
1423 isleapyear = (mod(year, 4) == 0 .AND. .NOT. mod(year, 100) == 0) &
1424 .OR. (mod(year, 400) == 0)
1425

References isleapyear().

Referenced by daysinmonth(), daysinyear(), and isleapyear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isocalendar()

integer function, dimension(3) mod_datetime::isocalendar ( class(datetime), intent(in) self)
private

Definition at line 1031 of file suews_util_datetime.f95.

1032
1033 !! Returns an array of 3 integers, year, week number, and week day,
1034 !! as defined by ISO 8601 week date. Essentially a wrapper around C
1035 !! `strftime` function.
1036
1037 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
1038
1039 INTEGER, DIMENSION(3) :: isocalendar
1040 INTEGER :: year, week, wday
1041 INTEGER :: rc
1042 CHARACTER(len=20) :: string
1043
1044 rc = c_strftime(string, len(string), '%G %V %u'//c_null_char, &
1045 self%tm())
1046
1047 READ (unit=string(1:4), fmt='(I4)') year
1048 READ (unit=string(6:7), fmt='(I2)') week
1049 READ (unit=string(9:9), fmt='(I1)') wday
1050
1051 isocalendar = [year, week, wday]
1052

References isocalendar().

Referenced by isocalendar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isoformat()

pure elemental character(len=23) function mod_datetime::isoformat ( class(datetime), intent(in) self,
character(len=1), intent(in), optional sep )
private

Definition at line 808 of file suews_util_datetime.f95.

809
810 !! Returns character string with time in ISO 8601 format.
811
812 CLASS(datetime), INTENT(in) :: self !! `datetime instance`
813 CHARACTER(len=1), INTENT(in), OPTIONAL :: sep
814 !! separator character, 'T' is default
815
816 CHARACTER(len=1) :: separator
817
818 IF (PRESENT(sep)) THEN
819 separator = sep
820 ELSE
821 separator = 'T'
822 END IF
823
824 ! TODO below is a bit cumbersome and was implemented
825 ! at a time before the interface to strftime. Now we
826 ! could do something like:
827 !
828 ! isoformat = self % strftime('%Y-%m-%d'//separator//'%H:%M:%S')
829 !
830 isoformat = int2str(self%year, 4)//'-'// &
831 int2str(self%month, 2)//'-'// &
832 int2str(self%day, 2)//separator// &
833 int2str(self%hour, 2)//':'// &
834 int2str(self%minute, 2)//':'// &
835 int2str(self%second, 2)//'.'// &
836 int2str(self%millisecond, 3)
837

References int2str(), and isoformat().

Referenced by isoformat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isoweekday()

pure elemental integer function mod_datetime::isoweekday ( class(datetime), intent(in) self)
private

Definition at line 952 of file suews_util_datetime.f95.

953
954 !! Returns the day of the week per ISO 8601 returned from weekday().
955 !! Returned value is an integer scalar in the range [1-7], such that:
956 !!
957 !! 1: Monday
958 !! 2: Tuesday
959 !! 3: Wednesday
960 !! 4: Thursday
961 !! 5: Friday
962 !! 6: Saturday
963 !! 7: Sunday
964
965 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
966
967 isoweekday = self%weekday()
968
969 IF (isoweekday == 0) THEN
970 isoweekday = 7
971 END IF
972

References isoweekday().

Referenced by isoweekday().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isoweekdaylong()

pure elemental character(len=9) function mod_datetime::isoweekdaylong ( class(datetime), intent(in) self)
private

Definition at line 989 of file suews_util_datetime.f95.

990
991 !! Returns the full name of the day of the week for ISO 8601
992 !! ordered weekdays.
993
994 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
995
996 CHARACTER(len=9), PARAMETER, DIMENSION(7) :: &
997 days = ['Monday ', 'Tuesday ', 'Wednesday', 'Thursday ', &
998 'Friday ', 'Saturday ', 'Sunday ']
999
1000 isoweekdaylong = days(self%isoweekday())
1001

References isoweekdaylong().

Referenced by isoweekdaylong().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isoweekdayshort()

pure elemental character(len=3) function mod_datetime::isoweekdayshort ( class(datetime), intent(in) self)
private

Definition at line 1017 of file suews_util_datetime.f95.

1018
1019 !! Returns the short (3-letter) name of the day of the week
1020 !! based on ISO 8601 ordering.
1021
1022 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
1023
1024 CHARACTER(len=3), PARAMETER, DIMENSION(7) :: &
1025 days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
1026
1027 isoweekdayshort = days(self%isoweekday())
1028

References isoweekdayshort().

Referenced by isoweekdayshort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isvalid()

pure elemental logical function mod_datetime::isvalid ( class(datetime), intent(in) self)
private

Definition at line 840 of file suews_util_datetime.f95.

841
842 !! Checks whether the `datetime` instance has valid component values.
843 !! Returns `.true.` if the `datetime` instance is valid, and `.false.`
844 !! otherwise.
845
846 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
847
848 ! assume valid
849 isvalid = .true.
850
851 IF (self%year < 1) THEN
852 isvalid = .false.
853 RETURN
854 END IF
855
856 IF (self%month < 1 .OR. self%month > 12) THEN
857 isvalid = .false.
858 RETURN
859 END IF
860
861 IF (self%day < 1 .OR. &
862 self%day > daysinmonth(self%month, self%year)) THEN
863 isvalid = .false.
864 RETURN
865 END IF
866
867 IF (self%hour < 0 .OR. self%hour > 23) THEN
868 isvalid = .false.
869 RETURN
870 END IF
871
872 IF (self%minute < 0 .OR. self%minute > 59) THEN
873 isvalid = .false.
874 RETURN
875 END IF
876
877 IF (self%second < 0 .OR. self%second > 59) THEN
878 isvalid = .false.
879 RETURN
880 END IF
881
882 IF (self%millisecond < 0 .OR. self%millisecond > 999) THEN
883 isvalid = .false.
884 RETURN
885 END IF
886

References daysinmonth(), and isvalid().

Referenced by isvalid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ le()

pure elemental logical function mod_datetime::le ( class(datetime), intent(in) d0,
class(datetime), intent(in) d1 )
private

Definition at line 1401 of file suews_util_datetime.f95.

1402
1403 !! `datetime` comparison operator. Returns `.true.` if `d0` is less
1404 !! than or equal to `d1`, and `.false.` otherwise. Overloads the
1405 !! operator `<=`.
1406
1407 CLASS(datetime), INTENT(in) :: d0 !! lhs `datetime` instance
1408 CLASS(datetime), INTENT(in) :: d1 !! rhs `datetime` instance
1409
1410 le = d1 > d0 .OR. d0 == d1
1411

References le().

Referenced by le().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lt()

pure elemental logical function mod_datetime::lt ( class(datetime), intent(in) d0,
class(datetime), intent(in) d1 )
private

Definition at line 1340 of file suews_util_datetime.f95.

1341
1342 !! `datetime` comparison operator that returns `.true.` if `d0` is
1343 !! less than `d1` and `.false.` otherwise. Overloads the operator `<`.
1344
1345 CLASS(datetime), INTENT(in) :: d0 !! lhs `datetime` instance
1346 CLASS(datetime), INTENT(in) :: d1 !! rhs `datetime` instance
1347
1348 lt = d1 > d0
1349

References lt().

Referenced by lt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ neq()

pure elemental logical function mod_datetime::neq ( class(datetime), intent(in) d0,
class(datetime), intent(in) d1 )
private

Definition at line 1376 of file suews_util_datetime.f95.

1377
1378 !! `datetime` comparison operator that eturns `.true.` if `d0` is
1379 !! not equal to `d1` and `.false.` otherwise. Overloads the operator `/=`.
1380
1381 CLASS(datetime), INTENT(in) :: d0 !! lhs `datetime` instance
1382 CLASS(datetime), INTENT(in) :: d1 !! rhs `datetime` instance
1383
1384 neq = .NOT. d0 == d1
1385

References neq().

Referenced by neq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ now()

type(datetime) function mod_datetime::now
private

Definition at line 889 of file suews_util_datetime.f95.

890
891 !! Returns a `datetime` instance with current time.
892 !! No input arguments.
893
894 CHARACTER(len=5) :: zone
895 INTEGER, DIMENSION(8) :: values
896
897 INTEGER :: hour, minute
898
899 ! Obtain local machine time zone information
900 CALL date_and_time(zone=zone, values=values)
901
902 READ (unit=zone(1:3), fmt='(I3)') hour
903 READ (unit=zone(4:5), fmt='(I2)') minute
904
905 now = datetime(year=values(1), &
906 month=values(2), &
907 day=values(3), &
908 hour=values(5), &
909 minute=values(6), &
910 second=values(7), &
911 millisecond=values(8))
912
913 now%tz = hour + minute*m2h
914

References now().

Referenced by now().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ num2date()

pure elemental type(datetime) function, public mod_datetime::num2date ( real(kind=real64), intent(in) num)

Definition at line 1536 of file suews_util_datetime.f95.

1537
1538 !! Given number of days since `0001-01-01 00:00:00`, returns a
1539 !! correspoding `datetime` instance.
1540
1541 REAL(kind=real64), INTENT(in) :: num
1542 !! number of days since `0001-01-01 00:00:00`
1543
1544 INTEGER :: year, month, day, hour, minute, second, millisecond
1545 REAL(kind=real64) :: days, totseconds
1546
1547 ! num must be positive:
1548 IF (num < 0) THEN
1549 num2date = datetime(1)
1550 RETURN
1551 END IF
1552
1553 days = num
1554
1555 year = 1
1556 DO
1557 IF (int(days) <= daysinyear(year)) EXIT
1558 days = days - daysinyear(year)
1559 year = year + 1
1560 END DO
1561
1562 month = 1
1563 DO
1564 IF (int(days) <= daysinmonth(month, year)) EXIT
1565 days = days - daysinmonth(month, year)
1566 month = month + 1
1567 END DO
1568
1569 day = int(days)
1570 totseconds = (days - day)*d2s
1571 hour = int(totseconds*s2h)
1572 minute = int((totseconds - hour*h2s)*s2m)
1573 second = int(totseconds - hour*h2s - minute*m2s)
1574 millisecond = nint((totseconds - int(totseconds))*1e3_real64)
1575
1576 num2date = datetime(year, month, day, hour, minute, second, millisecond, tz=zero)
1577
1578 ! Handle a special case caused by floating-point arithmethic:
1579 IF (num2date%millisecond == 1000) THEN
1580 num2date%millisecond = 0
1581 CALL num2date%addSeconds(1)
1582 END IF
1583
1584 IF (num2date%second == 60) THEN
1585 num2date%second = 0
1586 CALL num2date%addMinutes(1)
1587 END IF
1588 IF (num2date%minute == 60) THEN
1589 num2date%minute = 0
1590 CALL num2date%addHours(1)
1591 END IF
1592 IF (num2date%hour == 60) THEN
1593 num2date%hour = 0
1594 CALL num2date%addDays(1)
1595 END IF
1596

References daysinmonth(), daysinyear(), and num2date().

Referenced by datetimerange(), and num2date().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ secondssinceepoch()

integer function mod_datetime::secondssinceepoch ( class(datetime), intent(in) self)
private

Definition at line 1055 of file suews_util_datetime.f95.

1056
1057 !! Returns an integer number of seconds since the UNIX Epoch,
1058 !! `1970-01-01 00:00:00`. Note that this is a wrapper around C's
1059 !! `strftime('%s')`, so the number of seconds will reflect the time
1060 !! zone of the local machine on which the function is being called.
1061
1062 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
1063
1064 CHARACTER(len=11) :: string
1065
1066 string = self%strftime('%s')
1067 READ (unit=string, fmt='(I10)') secondssinceepoch
1068

References secondssinceepoch().

Referenced by secondssinceepoch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strftime()

character(len=:) function, allocatable mod_datetime::strftime ( class(datetime), intent(in) self,
character(len=*), intent(in) format )
private

Definition at line 1071 of file suews_util_datetime.f95.

1072
1073 !! Wrapper around C/C++ `strftime` function.
1074
1075 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
1076 CHARACTER(len=*), INTENT(in) :: FORMAT !! format string
1077
1078 CHARACTER(len=:), ALLOCATABLE :: strftime
1079
1080 INTEGER :: n, rc
1081 CHARACTER(len=MAXSTRLEN) :: resultString
1082
1083 resultstring = ""
1084 rc = c_strftime(resultstring, maxstrlen, trim(format)//c_null_char, &
1085 self%tm())
1086 strftime = trim(resultstring)
1087 n = len(strftime)
1088 strftime = strftime(1:n - 1)
1089

References strftime().

Referenced by strftime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ strptime()

type(datetime) function, public mod_datetime::strptime ( character(len=*), intent(in) str,
character(len=*), intent(in) format )

Definition at line 1599 of file suews_util_datetime.f95.

1600
1601 !! A wrapper function around C/C++ strptime function.
1602 !! Returns a `datetime` instance.
1603
1604 CHARACTER(len=*), INTENT(in) :: str !! time string
1605 CHARACTER(len=*), INTENT(in) :: FORMAT !! time format
1606
1607 INTEGER :: rc
1608 TYPE(tm_struct) :: tm
1609
1610 rc = c_strptime(trim(str)//c_null_char, trim(format)//c_null_char, tm)
1611 strptime = tm2date(tm)
1612

References strptime(), tm(), and tm2date().

Referenced by strptime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ timedelta_plus_datetime()

pure elemental type(datetime) function mod_datetime::timedelta_plus_datetime ( class(timedelta), intent(in) t,
class(datetime), intent(in) d0 )
private

Definition at line 1207 of file suews_util_datetime.f95.

1208
1209 !! Adds a `timedelta` instance to a `datetime` instance, and returns a
1210 !! new `datetime` instance. Overloads the operator `+`.
1211
1212 CLASS(timedelta), INTENT(in) :: t !! `timedelta` instance
1213 CLASS(datetime), INTENT(in) :: d0 !! `datetime` instance
1214 TYPE(datetime) :: d
1215
1216 d = d0 + t
1217

Referenced by mod_datetime::datetime::operator().

Here is the caller graph for this function:

◆ tm()

pure elemental type(tm_struct) function mod_datetime::tm ( class(datetime), intent(in) self)
private

Definition at line 1092 of file suews_util_datetime.f95.

1093
1094 !! Returns a `tm_struct` instance of the current `datetime`.
1095
1096 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
1097
1098 tm%tm_sec = self%second
1099 tm%tm_min = self%minute
1100 tm%tm_hour = self%hour
1101 tm%tm_mday = self%day
1102 tm%tm_mon = self%month - 1
1103 tm%tm_year = self%year - 1900
1104 tm%tm_wday = self%weekday()
1105 tm%tm_yday = self%yearday() - 1
1106 tm%tm_isdst = -1
1107

References tm().

Referenced by strptime(), and tm().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tm2date()

pure elemental type(datetime) function, public mod_datetime::tm2date ( type(tm_struct), intent(in) ctime)

Definition at line 1615 of file suews_util_datetime.f95.

1616
1617 !! Given a `tm_struct` instance, returns a corresponding `datetime`
1618 !! instance.
1619
1620 TYPE(tm_struct), INTENT(in) :: ctime !! C-style time struct
1621
1622 tm2date%millisecond = 0
1623 tm2date%second = ctime%tm_sec
1624 tm2date%minute = ctime%tm_min
1625 tm2date%hour = ctime%tm_hour
1626 tm2date%day = ctime%tm_mday
1627 tm2date%month = ctime%tm_mon + 1
1628 tm2date%year = ctime%tm_year + 1900
1629 tm2date%tz = 0
1630

References tm2date().

Referenced by strptime(), and tm2date().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tzoffset()

pure elemental character(len=5) function mod_datetime::tzoffset ( class(datetime), intent(in) self)
private

Definition at line 1110 of file suews_util_datetime.f95.

1111
1112 !! Returns a character string with timezone offset in hours from UTC,
1113 !! in format +/-[hh][mm].
1114
1115 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
1116
1117 INTEGER :: hours, minutes
1118
1119 IF (self%tz < 0) THEN
1120 tzoffset(1:1) = '-'
1121 ELSE
1122 tzoffset(1:1) = '+'
1123 END IF
1124
1125 hours = int(abs(self%tz))
1126 minutes = nint((abs(self%tz) - hours)*60)
1127
1128 IF (minutes == 60) THEN
1129 minutes = 0
1130 hours = hours + 1
1131 END IF
1132
1133 WRITE (unit=tzoffset(2:5), fmt='(2I2.2)') hours, minutes
1134

References tzoffset().

Referenced by tzoffset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ utc()

pure elemental type(datetime) function mod_datetime::utc ( class(datetime), intent(in) self)
private

Definition at line 1137 of file suews_util_datetime.f95.

1138
1139 !! Returns the `datetime` instance at Coordinated Universal Time (UTC).
1140
1141 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
1142
1143 INTEGER :: hours, minutes, sgn
1144
1145 hours = int(abs(self%tz))
1146 minutes = nint((abs(self%tz) - hours)*60)
1147 sgn = int(sign(one, self%tz))
1148
1149 utc = self - timedelta(hours=sgn*hours, minutes=sgn*minutes)
1150 utc%tz = 0
1151

References utc().

Referenced by utc().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ weekday()

pure elemental integer function mod_datetime::weekday ( class(datetime), intent(in) self)
private

Definition at line 917 of file suews_util_datetime.f95.

918
919 !! Returns the day of the week calculated using Zeller's congruence.
920 !! Returned value is an integer scalar in the range [0-6], such that:
921 !!
922 !! 0: Sunday
923 !! 1: Monday
924 !! 2: Tuesday
925 !! 3: Wednesday
926 !! 4: Thursday
927 !! 5: Friday
928 !! 6: Saturday
929
930 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
931
932 INTEGER :: year, month
933 INTEGER :: j, k
934
935 year = self%year
936 month = self%month
937
938 IF (month <= 2) THEN
939 month = month + 12
940 year = year - 1
941 END IF
942
943 j = year/100
944 k = mod(year, 100)
945
946 weekday = mod(self%day + ((month + 1)*26)/10 + k + k/4 + j/4 + 5*j, 7) - 1
947
948 IF (weekday < 0) weekday = 6
949

References weekday().

Referenced by weekday().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ weekdaylong()

pure elemental character(len=9) function mod_datetime::weekdaylong ( class(datetime), intent(in) self)
private

Definition at line 975 of file suews_util_datetime.f95.

976
977 !! Returns the full name of the day of the week.
978
979 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
980
981 CHARACTER(len=9), PARAMETER, DIMENSION(7) :: &
982 days = ['Sunday ', 'Monday ', 'Tuesday ', 'Wednesday', &
983 'Thursday ', 'Friday ', 'Saturday ']
984
985 weekdaylong = days(self%weekday() + 1)
986

References weekdaylong().

Referenced by weekdaylong().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ weekdayshort()

pure elemental character(len=3) function mod_datetime::weekdayshort ( class(datetime), intent(in) self)
private

Definition at line 1004 of file suews_util_datetime.f95.

1005
1006 !! Returns the short (3-letter) name of the day of the week.
1007
1008 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
1009
1010 CHARACTER(len=3), PARAMETER, DIMENSION(7) :: &
1011 days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
1012
1013 weekdayshort = days(self%weekday() + 1)
1014

References weekdayshort().

Referenced by weekdayshort().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ yearday()

pure elemental integer function mod_datetime::yearday ( class(datetime), intent(in) self)
private

Definition at line 1154 of file suews_util_datetime.f95.

1155
1156 !! Returns the integer day of the year (ordinal date).
1157
1158 CLASS(datetime), INTENT(in) :: self !! `datetime` instance
1159
1160 INTEGER :: month
1161
1162 yearday = 0
1163 DO month = 1, self%month - 1
1164 yearday = yearday + daysinmonth(month, self%year)
1165 END DO
1166 yearday = yearday + self%day
1167

References daysinmonth(), and yearday().

Referenced by yearday().

Here is the call graph for this function:
Here is the caller graph for this function: