Skip to content
Snippets Groups Projects
Commit ff7088fa authored by Jan Frederik Engels's avatar Jan Frederik Engels :new_moon:
Browse files

Rap divideInSecondsBy.

parent 5dff8c1b
No related branches found
No related tags found
No related merge requests found
......@@ -3,12 +3,14 @@ PROGRAM example
USE mtime, ONLY: setCalendar, PROLEPTIC_GREGORIAN
USE mtime_hl, ONLY: t_datetime, t_timedelta, min, max, &
& t_timedeltaFromMilliseconds
& t_timedeltaFromMilliseconds, &
& divisionquotienttimespan
IMPLICIT NONE
TYPE(t_datetime) :: dt, dt2, dt3, dt4
TYPE(t_timedelta) :: td
TYPE(t_timedelta) :: td, td1
TYPE(divisionquotienttimespan) :: dqts
INTEGER :: test_number1, test_number2, test_result
......@@ -69,5 +71,10 @@ PROGRAM example
! interval assignment with milliseconds
td = t_timedeltaFromMilliseconds(360000)
WRITE (0,*) "interval assignment with milliseconds: ", td%to_string()
! division
td1 = t_timedelta("PT23H42M")
dqts = td1%divideInSecondsBy(td)
WRITE (0,*) td1%to_string(), " / ", td%to_string(), " = ", dqts%quotient, " plus stuff"
END PROGRAM example
......@@ -20,6 +20,9 @@ module mtime_hl
PUBLIC :: t_timedeltaFromMilliseconds
PUBLIC :: min, max
! Re-export stuff from libmtime that is still needed
PUBLIC :: divisionquotienttimespan
integer, parameter :: i8 = selected_int_kind(14) !< at least 8 byte integer
......@@ -78,9 +81,12 @@ module mtime_hl
contains
procedure :: assign_t_timedelta
procedure :: t_timedelta_divideInSecondsBy
procedure :: t_timedelta_to_string
generic :: divideInSecondsBy => t_timedelta_divideInSecondsBy
generic :: to_string => t_timedelta_to_string
generic :: assignment(=) => assign_t_timedelta
......@@ -334,6 +340,14 @@ contains
call deallocatetimedelta(td_tmp)
end function t_timedelta_to_string
function t_timedelta_divideInSecondsBy (this, divisor) result(quotient)
CLASS(t_timedelta), INTENT(in) :: this
TYPE(t_timedelta), INTENT(in) :: divisor
TYPE(divisionquotienttimespan) :: quotient
CALL divideTimeDeltaInSeconds(this%td, divisor%td, quotient)
end function t_timedelta_divideInSecondsBy
function t_datetime_min(a,b) result(res)
type(t_datetime) :: a,b
type(t_datetime) :: res
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment