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

Add t_timedelta%toSeconds() / %toMilliSeconds()

parent 187d52ca
No related branches found
No related tags found
No related merge requests found
...@@ -80,4 +80,8 @@ PROGRAM example ...@@ -80,4 +80,8 @@ PROGRAM example
! produce error ! produce error
dt = t_datetime("1970--01-01T00:00:00") dt = t_datetime("1970--01-01T00:00:00")
! toSeconds, toMilliSeconds
WRITE (0,*) td%to_string(), " is in seconds ", td%toSeconds(dt)
WRITE (0,*) td%to_string(), " is in milliseconds ", td%toMilliSeconds(dt)
END PROGRAM example END PROGRAM example
...@@ -85,6 +85,8 @@ module mtime_hl ...@@ -85,6 +85,8 @@ module mtime_hl
procedure :: assign_t_timedelta procedure :: assign_t_timedelta
procedure :: t_timedelta_divideInSecondsBy procedure :: t_timedelta_divideInSecondsBy
procedure :: t_timedelta_toSeconds
procedure :: t_timedelta_toMilliSeconds
procedure :: equal_datetime => t_timedelta_equal procedure :: equal_datetime => t_timedelta_equal
procedure :: not_equal_datetime => t_timedelta_not_equal procedure :: not_equal_datetime => t_timedelta_not_equal
...@@ -100,6 +102,8 @@ module mtime_hl ...@@ -100,6 +102,8 @@ module mtime_hl
procedure :: t_timedelta_to_string procedure :: t_timedelta_to_string
generic :: divideInSecondsBy => t_timedelta_divideInSecondsBy generic :: divideInSecondsBy => t_timedelta_divideInSecondsBy
generic :: toSeconds => t_timedelta_toSeconds
generic :: toMilliSeconds => t_timedelta_toMilliSeconds
generic :: to_string => t_timedelta_to_string generic :: to_string => t_timedelta_to_string
...@@ -524,6 +528,22 @@ contains ...@@ -524,6 +528,22 @@ contains
CALL divideTimeDeltaInSeconds(this%td, divisor%td, quotient) CALL divideTimeDeltaInSeconds(this%td, divisor%td, quotient)
end function t_timedelta_divideInSecondsBy end function t_timedelta_divideInSecondsBy
function t_timedelta_toSeconds (this, td) result(seconds)
CLASS(t_timedelta), INTENT(in) :: this
TYPE(t_datetime), INTENT(in) :: td
INTEGER(c_int64_t) :: seconds
seconds = getTotalSecondsTimeDelta(this%td, td%dt)
end function t_timedelta_toSeconds
function t_timedelta_toMilliSeconds (this, td) result(ms)
CLASS(t_timedelta), INTENT(in) :: this
TYPE(t_datetime), INTENT(in) :: td
INTEGER(c_int64_t) :: ms
ms = getTotalMilliSecondsTimeDelta(this%td, td%dt)
end function t_timedelta_toMilliSeconds
function t_datetime_min(a,b) result(res) function t_datetime_min(a,b) result(res)
type(t_datetime) :: a,b type(t_datetime) :: a,b
type(t_datetime) :: res 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