155 integer(i4),
public :: year = 1_i4
156 integer(i4),
public :: month = 1_i4
157 integer(i4),
public :: day = 1_i4
203 integer(i4),
public :: hour = 0_i4
204 integer(i4),
public :: minute = 0_i4
205 integer(i4),
public :: second = 0_i4
224 generic,
public ::
assignment(=) =>
t_copy
226 generic,
public ::
operator(==) =>
t_eq
228 generic,
public ::
operator(/=) =>
t_neq
230 generic,
public ::
operator(<) =>
t_lt
232 generic,
public ::
operator(>) =>
t_gt
234 generic,
public ::
operator(<=) =>
t_leq
236 generic,
public ::
operator(>=) =>
t_geq
247 integer(i4),
public :: year = 1_i4
248 integer(i4),
public :: month = 1_i4
249 integer(i4),
public :: day = 1_i4
250 integer(i4),
public :: hour = 0_i4
251 integer(i4),
public :: minute = 0_i4
252 integer(i4),
public :: second = 0_i4
304 integer(i4),
public :: days = 0_i4
305 integer(i4),
public :: seconds = 0_i4
314 generic,
public ::
operator(==) =>
td_eq
316 generic,
public ::
operator(/=) =>
td_neq
318 generic,
public ::
operator(<) =>
td_lt
320 generic,
public ::
operator(>) =>
td_gt
322 generic,
public ::
operator(<=) =>
td_leq
324 generic,
public ::
operator(>=) =>
td_geq
422 integer(i4),
intent(in) :: hour
432 integer(i4) :: values(8)
433 call date_and_time(values=values)
434 now =
dt_init(year=values(1), month=values(2), day=values(3), hour=values(5), minute=values(6), second=values(7))
452 pure integer(i4) function weekday(year, month, day)
454 integer(i4),
intent(in) :: year
455 integer(i4),
intent(in) :: month
456 integer(i4),
intent(in) :: day
457 integer(i4) :: year_j, year_k, mon, yea
466 year_j = yea / 100_i4
467 year_k = mod(yea, 100_i4)
468 weekday = mod(day + (13_i4*(mon+1_i4))/5_i4 + year_k + year_k/4_i4 + year_j/4_i4 + 5_i4*year_j,
week_days)
477 integer(i4),
intent(in) :: year
478 is_leap_year = mod(year, 4_i4) == 0_i4 .and. (mod(year, 100_i4) /= 0_i4 .or. mod(year, 400_i4) == 0_i4)
484 integer(i4),
intent(in) :: year
485 integer(i4),
intent(in) :: month
487 if (month == 2_i4)
then
493 if ((mod(month, 2) == 0 .and. month < 8) .or. (mod(month, 2) == 1 .and. month >= 8))
then
503 integer(i4),
intent(in) :: year
511 integer(i4),
intent(in) :: year
520 integer(i4),
intent(in) :: year
521 integer(i4),
intent(in) :: doy
522 integer(i4),
intent(out),
optional :: month
523 integer(i4),
intent(out),
optional :: day
524 integer(i4) :: i, dim, remain
529 if (remain <= dim)
exit
530 remain = remain - dim
532 if (
present(month)) month = i
533 if (
present(day)) day = remain
539 integer(i4),
intent(in) :: year
541 call error_message(
"datetime: year is out of range. Got: ", num2str(year))
547 integer(i4),
intent(in) :: month
549 call error_message(
"datetime: month is out of range. Got: ", num2str(month))
555 integer(i4),
intent(in) :: year
556 integer(i4),
intent(in) :: month
557 integer(i4),
intent(in) :: day
559 call error_message(
"datetime: day is out of range. Got: ", num2str(day))
565 integer(i4),
intent(in),
optional :: hour
566 if (hour < 0_i4 .or. hour >=
day_hours) &
567 call error_message(
"datetime: hour is out of range. Got: ", num2str(hour))
573 integer(i4),
intent(in),
optional :: minute
575 call error_message(
"datetime: minute is out of range. Got: ", num2str(minute))
581 integer(i4),
intent(in),
optional :: second
583 call error_message(
"datetime: second is out of range. Got: ", num2str(second))
589 integer(i4),
intent(in),
optional :: year
590 integer(i4),
intent(in),
optional :: month
591 integer(i4),
intent(in),
optional :: day
592 integer(i4),
intent(in),
optional :: hour
593 integer(i4),
intent(in),
optional :: minute
594 integer(i4),
intent(in),
optional :: second
596 if (
present(day) .and. .not. (
present(year) .and.
present(month))) &
597 call error_message(
"check_datetime: to validate a given 'day', 'year' and 'month' are required.")
601 if (
present(day))
call check_day(year, month, day)
610 function dt_init(year, month, day, hour, minute, second)
result(out)
612 integer(i4),
intent(in),
optional :: year
613 integer(i4),
intent(in),
optional :: month
614 integer(i4),
intent(in),
optional :: day
615 integer(i4),
intent(in),
optional :: hour
616 integer(i4),
intent(in),
optional :: minute
617 integer(i4),
intent(in),
optional :: second
620 if (
present(year)) out%year = year
622 if (
present(month)) out%month = month
624 if (
present(day)) out%day = day
626 if (
present(hour)) out%hour = hour
628 if (
present(minute)) out%minute = minute
630 if (
present(second)) out%second = second
632 call check_datetime(year=out%year, month=out%month, day=out%day, hour=out%hour, minute=out%minute, second=out%second)
638 character(*),
intent(in) :: string
641 character(256),
dimension(:),
allocatable :: str_arr
652 character(*),
intent(in) :: string
653 integer(i4),
intent(in) :: value
657 character(256),
dimension(:),
allocatable :: str_arr
659 select case(trim(str_arr(1)))
669 call error_message(
"datetime: units not valid for a cf-convetion time. Got: ", trim(str_arr(1)))
671 if (trim(str_arr(2)) /=
"since")
call error_message(
"datetime: expected 'since' for cf-convetion. Got: ", trim(str_arr(2)))
681 class(
puredate),
intent(in) :: in_date
682 class(
puretime),
intent(in),
optional :: in_time
686 if (
present(in_time)) in_time_ = in_time
687 out%year = in_date%year
688 out%month = in_date%month
689 out%day = in_date%day
690 out%hour = in_time_%hour
691 out%minute = in_time_%minute
692 out%second = in_time_%second
697 real(dp),
intent(in) :: julian
698 integer(i4),
intent(in),
optional :: calendar
699 integer(i4) :: year, month, day, hour, minute, second
700 call dec2date(julian, yy=year, mm=month, dd=day, hh=hour, nn=minute, ss=second, calendar=calendar)
713 integer(i4),
intent(in),
optional :: year
714 integer(i4),
intent(in),
optional :: month
715 integer(i4),
intent(in),
optional :: day
716 integer(i4),
intent(in),
optional :: hour
717 integer(i4),
intent(in),
optional :: minute
718 integer(i4),
intent(in),
optional :: second
719 integer(i4) :: new_year, new_month, new_day, new_hour, new_minute, new_second
721 new_month = this%month
724 new_minute = this%minute
725 new_second = this%second
726 if (
present(year)) new_year = year
727 if (
present(month)) new_month = month
728 if (
present(day)) new_day = day
729 if (
present(hour)) new_hour = hour
730 if (
present(minute)) new_minute = minute
731 if (
present(second)) new_second = second
732 dt_replace =
dt_init(new_year, new_month, new_day, new_hour, new_minute, new_second)
738 class(
datetime),
intent(inout) :: this
740 this%year = that%year
741 this%month = that%month
743 this%hour = that%hour
744 this%minute = that%minute
745 this%second = that%second
751 class(
datetime),
intent(inout) :: this
753 this%year = that%year
754 this%month = that%month
790 integer(i4),
intent(in),
optional :: calendar
791 dt_julian = date2dec(yy=this%year, mm=this%month, dd=this%day, hh=this%hour, nn=this%minute, ss=this%second, calendar=calendar)
812 is_new_year = this%is_new_month() .and. this%month == 1_i4
826 is_new_week = this%is_new_day() .and. this%weekday() == 1_i4
833 is_new_day = this%is_new_hour() .and. this%hour == 0_i4
840 is_new_hour = this%is_new_minute() .and. this%minute == 0_i4
851 pure logical function dt_eq(this, that)
853 class(
datetime),
intent(in) :: this, that
854 dt_eq = this%date() == that%date() .and. this%time() == that%time()
868 class(
datetime),
intent(in) :: this, that
881 pure logical function dt_lt(this, that)
883 class(
datetime),
intent(in) :: this, that
884 dt_lt = this%date() < that%date() .or. (this%date() == that%date() .and. this%time() < that%time())
897 pure logical function dt_gt(this, that)
899 class(
datetime),
intent(in) :: this, that
915 class(
datetime),
intent(in) :: this, that
931 class(
datetime),
intent(in) :: this, that
953 temp =
td_init(days=that%days, seconds=this%second+that%seconds, minutes=this%minute, hours=this%hour)
955 new_date = this%date() + temp
979 class(
datetime),
intent(in) :: this, that
981 integer(i4) :: minyear, maxyear, days_this, days_that, day_year_diff, i
982 minyear = min(this%year, that%year)
983 maxyear = max(this%year, that%year)
986 do i=minyear, maxyear-1_i4
989 days_this = this%doy()
990 days_that = that%doy()
991 if (this%year < that%year) days_that = days_that + day_year_diff
992 if (this%year > that%year) days_this = days_this + day_year_diff
994 tmp_this =
timedelta(days=days_this, seconds=this%second, minutes=this%minute, hours=this%hour)
995 tmp_that =
timedelta(days=days_that, seconds=that%second, minutes=that%minute, hours=that%hour)
1002 class(
datetime),
intent(in) :: this
1003 class(
puredate),
intent(in) :: that
1010 function d_init(year, month, day)
result(out)
1012 integer(i4),
intent(in),
optional :: year
1013 integer(i4),
intent(in),
optional :: month
1014 integer(i4),
intent(in),
optional :: day
1017 if (
present(year)) out%year = year
1019 if (
present(month)) out%month = month
1021 if (
present(day)) out%day = day
1028 character(*),
intent(in) :: string
1029 character(256),
dimension(:),
allocatable :: date_str
1030 integer(i4) :: year, month, day
1032 read(date_str(1), *) year
1033 read(date_str(2), *) month
1034 read(date_str(3), *) day
1040 real(dp),
intent(in) :: julian
1041 integer(i4),
intent(in),
optional :: calendar
1042 integer(i4) :: year, month, day
1043 call dec2date(julian, yy=year, mm=month, dd=day, calendar=calendar)
1052 class(
puredate),
intent(in) :: this
1053 integer(i4),
intent(in),
optional :: year
1054 integer(i4),
intent(in),
optional :: month
1055 integer(i4),
intent(in),
optional :: day
1056 integer(i4) :: new_year, new_month, new_day
1057 new_year = this%year
1058 new_month = this%month
1060 if (
present(year)) new_year = year
1061 if (
present(month)) new_month = month
1062 if (
present(day)) new_day = day
1069 class(
puredate),
intent(in) :: this
1076 class(
puredate),
intent(in) :: this
1083 class(
puredate),
intent(in) :: this
1084 write(
d_str,
"(i4.4, '-' ,i2.2, '-', i2.2)") this%year, this%month, this%day
1090 class(
puredate),
intent(in) :: this
1091 integer(i4),
intent(in),
optional :: calendar
1092 d_julian = date2dec(yy=this%year, mm=this%month, dd=this%day, calendar=calendar)
1098 class(
puredate),
intent(in) :: this
1105 class(
puredate),
intent(in) :: this
1108 do i=1_i4, this%month-1_i4
1116 class(
puredate),
intent(in) :: this
1117 d_is_new_year = this%is_new_month() .and. this%month == 1_i4
1123 class(
puredate),
intent(in) :: this
1130 class(
puredate),
intent(in) :: this
1135 pure logical function d_eq(this, that)
1137 class(
puredate),
intent(in) :: this, that
1138 d_eq = this%to_ordinal() == that%to_ordinal()
1144 class(
puredate),
intent(in) :: this
1145 class(
datetime),
intent(in) :: that
1152 class(
puredate),
intent(in) :: this, that
1159 class(
puredate),
intent(in) :: this
1160 class(
datetime),
intent(in) :: that
1165 pure logical function d_lt(this, that)
1167 class(
puredate),
intent(in) :: this, that
1168 d_lt = this%to_ordinal() < that%to_ordinal()
1174 class(
puredate),
intent(in) :: this
1175 class(
datetime),
intent(in) :: that
1180 pure logical function d_gt(this, that)
1182 class(
puredate),
intent(in) :: this, that
1189 class(
puredate),
intent(in) :: this
1190 class(
datetime),
intent(in) :: that
1197 class(
puredate),
intent(in) :: this, that
1204 class(
puredate),
intent(in) :: this
1205 class(
datetime),
intent(in) :: that
1212 class(
puredate),
intent(in) :: this, that
1219 class(
puredate),
intent(in) :: this
1220 class(
datetime),
intent(in) :: that
1227 class(
puredate),
intent(in) :: this
1229 integer(i4) :: new_year, new_month, new_day, day_delta, diy
1231 new_year = this%year
1232 day_delta = this%doy() + that%days
1233 if (day_delta > 0_i4)
then
1236 if (day_delta <= diy)
exit
1237 new_year = new_year + 1_i4
1238 day_delta = day_delta - diy
1242 new_year = new_year - 1_i4
1244 day_delta = day_delta + diy
1245 if (day_delta > 0_i4)
exit
1249 call doy_to_month_day(year=new_year, doy=day_delta, month=new_month, day=new_day)
1258 class(
puredate),
intent(in) :: this
1266 class(
puredate),
intent(in) :: this
1274 class(
puredate),
intent(in) :: this, that
1276 d_sub_d = this%to_datetime() - that%to_datetime()
1282 class(
puredate),
intent(in) :: this
1283 class(
datetime),
intent(in) :: that
1285 d_sub_dt = this%to_datetime() - that
1291 function t_init(hour, minute, second)
result(out)
1293 integer(i4),
intent(in) :: hour
1294 integer(i4),
intent(in) :: minute
1295 integer(i4),
intent(in),
optional :: second
1300 if (
present(second)) out%second = second
1302 call check_datetime(hour=out%hour, minute=out%minute, second=out%second)
1308 character(*),
intent(in) :: string
1309 character(256),
dimension(:),
allocatable :: time_str
1310 integer(i4) :: hour, minute, second
1312 read(time_str(1), *) hour
1313 read(time_str(2), *) minute
1314 read(time_str(3), *) second
1321 integer(i4),
intent(in) :: day_second
1322 integer(i4) :: temp_seconds
1324 temp_seconds = min(max(day_second, 0_i4),
day_seconds-1_i4)
1335 class(
puretime),
intent(inout) :: this
1336 class(
puretime),
intent(in) :: that
1337 this%hour = that%hour
1338 this%minute = that%minute
1339 this%second = that%second
1345 class(
puretime),
intent(in) :: this
1346 integer(i4),
intent(in),
optional :: hour
1347 integer(i4),
intent(in),
optional :: minute
1348 integer(i4),
intent(in),
optional :: second
1349 integer(i4) :: new_hour, new_minute, new_second
1350 new_hour = this%hour
1351 new_minute = this%minute
1352 new_second = this%second
1353 if (
present(hour)) new_hour = hour
1354 if (
present(minute)) new_minute = minute
1355 if (
present(second)) new_second = second
1362 class(
puretime),
intent(in) :: this
1363 write(
t_str,
"(i2.2, ':', i2.2, ':', i2.2)") this%hour, this%minute, this%second
1369 class(
puretime),
intent(in) :: this
1376 class(
puretime),
intent(in) :: this
1377 t_is_new_day = this%is_new_hour() .and. this%hour == 0_i4
1383 class(
puretime),
intent(in) :: this
1384 t_is_new_hour = this%is_new_minute() .and. this%minute == 0_i4
1390 class(
puretime),
intent(in) :: this
1395 pure logical function t_eq(this, that)
1397 class(
puretime),
intent(in) :: this, that
1398 t_eq = this%day_second() == that%day_second()
1404 class(
puretime),
intent(in) :: this, that
1409 pure logical function t_lt(this, that)
1411 class(
puretime),
intent(in) :: this, that
1412 t_lt = this%day_second() < that%day_second()
1416 pure logical function t_gt(this, that)
1418 class(
puretime),
intent(in) :: this, that
1419 t_gt = this%day_second() > that%day_second()
1425 class(
puretime),
intent(in) :: this, that
1426 t_leq = this%day_second() <= that%day_second()
1432 class(
puretime),
intent(in) :: this, that
1433 t_geq = this%day_second() >= that%day_second()
1439 class(
puretime),
intent(in) :: this
1448 class(
puretime),
intent(in) :: this
1456 class(
puretime),
intent(in) :: this
1464 class(
puretime),
intent(in) :: this, that
1472 pure function td_init(days, seconds, minutes, hours, weeks)
result(out)
1474 integer(i4),
intent(in),
optional :: days
1475 integer(i4),
intent(in),
optional :: seconds
1476 integer(i4),
intent(in),
optional :: minutes
1477 integer(i4),
intent(in),
optional :: hours
1478 integer(i4),
intent(in),
optional :: weeks
1480 integer(i4) :: neg_days, remain_sec
1482 if (
present(days)) out%days = days
1483 if (
present(weeks)) out%days = out%days + weeks *
week_days
1484 if (
present(seconds)) out%seconds = seconds
1485 if (
present(minutes)) out%seconds = out%seconds + minutes *
minute_seconds
1486 if (
present(hours)) out%seconds = out%seconds + hours *
hour_seconds
1489 if (out%seconds < 0)
then
1493 out%seconds = out%seconds + neg_days *
day_seconds
1494 out%days = out%days - neg_days
1496 if (remain_sec > 0)
then
1498 out%days = out%days - 1_i4
1503 out%seconds = out%seconds - neg_days *
day_seconds
1504 out%days = out%days + neg_days
1512 integer(i4) :: days, seconds
1513 if (this%days < 0_i4)
then
1515 seconds = -this%seconds
1518 seconds = this%seconds
1530 pure type(
timedelta) function from_total_seconds(total_seconds)
1531 integer(i8),
intent(in) :: total_seconds
1532 integer(i8) :: daysec
1534 from_total_seconds =
timedelta(days=int(total_seconds / daysec, i4), seconds=int(mod(total_seconds, daysec), i4))
1535 end function from_total_seconds
1542 this%days = that%days
1543 this%seconds = that%seconds
1549 class(
timedelta),
intent(in) :: this, that
1550 td_eq = this%total_seconds() == that%total_seconds()
1556 class(
timedelta),
intent(in) :: this, that
1563 class(
timedelta),
intent(in) :: this, that
1564 td_lt = this%total_seconds() < that%total_seconds()
1570 class(
timedelta),
intent(in) :: this, that
1571 td_gt = this%total_seconds() > that%total_seconds()
1577 class(
timedelta),
intent(in) :: this, that
1578 td_leq = this%total_seconds() <= that%total_seconds()
1584 class(
timedelta),
intent(in) :: this, that
1585 td_geq = this%total_seconds() >= that%total_seconds()
1591 class(
timedelta),
intent(in) :: this, that
1592 td_add =
timedelta(days=this%days+that%days, seconds=this%seconds+that%seconds)
1598 class(
timedelta),
intent(in) :: this, that
1599 td_sub =
timedelta(days=this%days-that%days, seconds=this%seconds-that%seconds)
1620 integer(i4),
intent(in) :: that
1628 integer(i4),
intent(in) :: that
1636 real(dp),
intent(in) :: that
1637 td_mul1_dp = from_total_seconds(int(this%total_seconds() * that, i8))
1644 real(dp),
intent(in) :: that
1652 integer(i4),
intent(in) :: that
1653 td_div = from_total_seconds(this%total_seconds() / int(that, i8))
1660 real(dp),
intent(in) :: that
1667 class(
timedelta),
intent(in) :: this, that
1668 td_div_td = real(this%total_seconds(), dp) / real(that%total_seconds(), dp)
Types to deal with datetimes.
pure type(datetime) function dt_add_td(this, that)
add a timedelta to a datetime
pure type(timedelta) function dt_sub_dt(this, that)
difference between two datetimes
pure logical function t_is_new_day(this)
time is a new day / midnight
pure logical function td_gt(this, that)
greater than comparison of timedeltas
pure logical function dt_gt_d(this, that)
greater than comparison of datetime and date
pure type(puretime) function, public midday()
midday (12:00)
pure logical function dt_geq_d(this, that)
less than or equal comparison of datetime and date
pure type(timedelta) function td_div(this, that)
divide a timedelta by an integer
subroutine check_minute(minute)
check if a given minute is valid
pure type(puretime) function td_add_t(that, this)
add a timedelta to a time
pure logical function dt_lt_d(this, that)
less than comparison of datetime and date
pure type(puredate) function get_date(this)
date of the datetime
pure type(datetime) function td_add_dt(that, this)
add a timedelta to a datetime
pure logical function t_eq(this, that)
equal comparison of times
pure subroutine t_copy(this, that)
copy a time
pure logical function d_geq_dt(this, that)
greater than or equal comparison of date and datetime
type(puretime) function, public currently()
get current puretime
type(puretime) function t_init(hour, minute, second)
initialize a time
pure type(puretime) function t_add_td(this, that)
add a timedelta to a time
pure logical function is_new_hour(this)
datetime is a new hour
pure type(puretime) function t_sub_td(this, that)
subtract a timedelta from a time
integer(i4), parameter, public day_minutes
minutes in day
integer(i4), parameter, public day_seconds
seconds in day
pure type(puredate) function d_from_julian(julian, calendar)
date from fractional julian day
subroutine check_day(year, month, day)
check if a given day is valid
pure logical function is_new_year(this)
datetime is a new year
pure logical function d_geq(this, that)
greater than or equal comparison of dates
pure logical function td_lt(this, that)
less than comparison of timedeltas
pure logical function dt_lt(this, that)
less than comparison of datetimes
pure type(puretime) function t_from_day_second(day_second)
time from day second
pure logical function, public is_leap_year(year)
whether a given year is a leap year
pure character(8) function t_str(this)
string representation of the time
pure type(datetime) function dt_from_julian(julian, calendar)
datetime from fractional julian day
pure logical function t_geq(this, that)
greater than or equal comparison of times
pure logical function t_is_new_hour(this)
time is a new hour
pure type(puretime) function get_time(this)
time of the datetime
pure integer(i4) function dt_doy(this)
day of the year
type(puredate) function, public today()
get todays puredate
pure logical function dt_eq_d(this, that)
equal comparison of datetime and date
pure character(10) function d_str(this)
string representation of the date
pure type(puredate) function d_sub_td(this, that)
subtract a timedelta from a date
integer(i4), parameter, public week_hours
hours in week
pure logical function d_neq(this, that)
not equal comparison of dates
pure type(timedelta) function td_mul2_dp(that, this)
multiply a timedelta with a real
pure logical function td_leq(this, that)
less than or equal comparison of timedeltas
pure logical function dt_eq(this, that)
equal comparison of datetimes
integer(i4), parameter, public year_months
months in year
integer(i4), parameter, public leap_year_days
days in leap year
type(puredate) function d_from_string(string)
date from string
pure logical function d_lt(this, that)
less than comparison of dates
type(datetime) function dt_from_string(string)
datetime from string
pure logical function d_eq_dt(this, that)
equal comparison of date and datetime
pure logical function d_is_new_month(this)
date is a new month
type(puredate) function d_replace(this, year, month, day)
new date with specified fields
pure logical function dt_gt(this, that)
greater than comparison of datetimes
pure type(timedelta) function, public one_hour()
one hour time delta
pure logical function t_neq(this, that)
not equal comparison of times
pure logical function dt_neq_d(this, that)
not equal comparison of datetime and date
pure type(timedelta) function td_init(days, seconds, minutes, hours, weeks)
initialize a timedelta
pure integer(i4) function, public days_in_month(year, month)
number of days in a given month
pure integer(i4) function t_day_second(this)
time to second of the day
pure real(dp) function d_julian(this, calendar)
date as fractional julian day
pure real(dp) function td_div_td(this, that)
divide a timedelta by a timedelta
pure real(dp) function dt_julian(this, calendar)
datetime as fractional julian day
type(puretime) function t_from_string(string)
time from string
integer(i4), parameter min_year
minimum for year
pure type(timedelta) function d_sub_d(this, that)
difference between two dates
pure type(timedelta) function td_sub(this, that)
adding two timedeltas
type(puredate) function d_init(year, month, day)
initialize a date
pure character(19) function dt_str(this)
string representation of the datetime
pure logical function d_is_new_week(this)
date is a new week
pure type(timedelta) function, public one_minute()
one minute time delta
integer(i4), parameter, public minute_seconds
seconds in minute
pure integer(i4) function weekday(year, month, day)
day of the week
pure subroutine dt_copy_dt(this, that)
copy a datetime
pure logical function t_gt(this, that)
greater than comparison of times
pure logical function d_eq(this, that)
equal comparison of dates
pure integer(i4) function d_weekday(this)
day of the week
pure type(timedelta) function dt_sub_d(this, that)
difference between datetime and date
subroutine check_datetime(year, month, day, hour, minute, second)
check if a datetime is valid
pure type(puretime) function, public day_hour(hour)
time for given hour
pure logical function dt_geq(this, that)
greater than or equal comparison of datetimes
pure logical function d_lt_dt(this, that)
less than comparison of date and datetime
subroutine check_second(second)
check if a given second is valid
pure type(puredate) function d_add_td(this, that)
add a timedelta to a date
pure type(timedelta) function td_mul1(this, that)
multiply a timedelta with an integer
integer(i4), parameter, public hour_minutes
minutes in hour
integer(i4), parameter, public week_days
days in week
pure subroutine dt_copy_d(this, that)
copy a datetime from a date
subroutine check_hour(hour)
check if a given hour is valid
pure logical function d_is_new_year(this)
date is a new year
pure logical function d_leq(this, that)
less than or equal comparison of dates
pure type(timedelta) function, public one_week()
one week time delta
pure type(timedelta) function, public zero_delta()
zero time delta
pure logical function dt_leq_d(this, that)
less than or equal comparison of datetime and date
pure subroutine td_copy(this, that)
copy a timedelta
pure type(timedelta) function td_div_dp(this, that)
divide a timedelta by a real
pure logical function td_geq(this, that)
greater than or equal comparison of timedeltas
subroutine check_month(month)
check if a given month is valid
pure integer(i4) function d_doy(this)
day of the year
pure logical function td_neq(this, that)
not equal comparison of timedeltas
pure logical function dt_leq(this, that)
less than or equal comparison of datetimes
type(datetime) function dt_replace(this, year, month, day, hour, minute, second)
new datetime with specified fields
integer(i4), parameter max_year
maximum for year
pure logical function t_lt(this, that)
less than comparison of times
pure integer(i4) function dt_weekday(this)
day of the week
pure logical function dt_neq(this, that)
not equal comparison of datetimes
pure subroutine doy_to_month_day(year, doy, month, day)
get date from day of the year
pure integer(i4) function days_before_year(year)
number of days before a given year since year 1
pure type(timedelta) function td_add(this, that)
adding two timedeltas
pure type(timedelta) function, public one_second()
one second time delta
pure logical function t_is_new_minute(this)
time is a new month
pure type(timedelta) function td_mul1_dp(this, that)
multiply a timedelta with a real
subroutine check_year(year)
check if a given year is valid
pure type(datetime) function to_datetime(this)
convert date to a datetime
pure type(timedelta) function d_sub_dt(this, that)
difference between date and datetime
pure type(timedelta) function td_pos(this)
positive timedelta
pure type(timedelta) function td_abs(this)
absolute timedelta
pure logical function d_gt_dt(this, that)
greater than comparison of date and datetime
pure type(timedelta) function td_neg(this)
negative timedelta
pure type(timedelta) function t_sub_t(this, that)
difference between two times
pure type(puretime) function, public midnight()
midnight (00:00)
pure logical function d_gt(this, that)
greater than comparison of dates
type(datetime) function dt_init(year, month, day, hour, minute, second)
initialize a datetime
integer(i4), parameter, public day_hours
hours in day
pure type(timedelta) function td_mul2(that, this)
multiply a timedelta with an integer
integer(i4), parameter, public week_minutes
minutes in week
pure integer(i4) function, public days_in_year(year)
number of days in a given year
integer(i4), parameter, public clock_hours
hours on a clock
pure logical function is_new_day(this)
datetime is a new day
pure logical function t_leq(this, that)
less than or equal comparison of times
integer(i4), parameter, public week_seconds
seconds in week
pure type(timedelta) function, public one_day()
one day time delta
integer(i4), parameter, public year_days
days in standard year
pure logical function td_eq(this, that)
equal comparison of timedeltas
pure logical function d_neq_dt(this, that)
not equal comparison of date and datetime
pure logical function d_leq_dt(this, that)
less than or equal comparison of date and datetime
pure logical function is_new_minute(this)
datetime is a new month
pure logical function is_new_week(this)
datetime is a new week
type(puretime) function t_replace(this, hour, minute, second)
new time with specified fields
pure integer(i8) function td_total_seconds(this)
timedelta in seconds (may need i8)
pure type(datetime) function dt_from_date_time(in_date, in_time)
datetime from date and time
type(datetime) function dt_from_cf(string, value)
datetime from cf-string and value
pure logical function is_new_month(this)
datetime is a new month
pure type(datetime) function dt_sub_td(this, that)
subtract a timedelta from a datetime
pure integer(i4) function to_ordinal(this)
convert date to number of days since year 1
integer(i4), parameter, public hour_seconds
seconds in hour
type(datetime) function, public now()
get current datetime
pure type(puredate) function td_add_d(that, this)
add a timedelta to a date
Julian date conversion routines.
elemental real(dp) function, public date2dec(dd, mm, yy, hh, nn, ss, calendar)
Fractional Julian day from day, month, year, hour, minute, second in the current calendar.
elemental subroutine, public dec2date(julian, dd, mm, yy, hh, nn, ss, calendar)
Day, month, year, hour, minute, and second from fractional Julian day in the current or given calenda...
Define number representations.
integer, parameter i4
4 Byte Integer Kind
integer, parameter i8
8 Byte Integer Kind
integer, parameter dp
Double Precision Real Kind.
Write out concatenated strings.
subroutine, public error_message(t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, uni, advance, show, raise, reset_format)
Write out an error message to stderr and call stop 1.
subroutine, public divide_string(string, delim, strarr)
Divide string in substrings.
This is a container to hold a date-time.
This is a container to hold only a date.
This is a container to hold only a time.
This is a container to hold a defined time span.