u2d(3f) - [M_time:UNIX_EPOCH] given Unix Epoch Time returns DAT date-time array (LICENSE:MIT)
Synopsis
Description
Options
Returns
Example
Author
License
function u2d(unixtime) result(dat)
class(*),intent(in),optional :: unixtime ! integer ! real ! real(kind=realtime)integer :: dat(8)
Given Unix Epoch Time returns DAT date-time array
unixtime The "Unix Epoch" time, or the number of seconds since 00:00:00 on January 1st, 1970, UTC. If not present, use current time.
dat Integer array holding a "DAT" array, similar in structure to the array returned by the intrinsic DATE_AND_TIME(3f): dat=[ year,month,day,timezone,hour,& & minutes,seconds,milliseconds]
Sample program:
program demo_u2d use M_time, only : u2d, d2u, fmtdate, realtime implicit none integer,parameter :: dp=kind(0.0d0) real(kind=realtime) :: today integer :: dat(8) ! get the date using intrinsic call date_and_time(values=dat) ! convert today to Julian Date today=d2u(dat) write(*,*)Today=,fmtdate(u2d(today)) ! subtract day write(*,*)Yesterday=,fmtdate(u2d(today-86400.0_dp)) ! add day write(*,*)Tomorrow=,fmtdate(u2d(today+86400.0_dp)) end program demo_u2dresults:
Today=Tuesday, July 19th, 2016 11:10:08 AM Yesterday=Monday, July 18th, 2016 11:10:08 AM Tomorrow=Wednesday, July 20th, 2016 11:10:08 AM
John S. Urban, 2015
Nemo Release 3.1 | u2d (3) | February 23, 2025 |