unix_to_date(3f) - [M_time:UNIX_EPOCH] converts Unix Epoch Time to DAT date-time array (LICENSE:MIT)
Synopsis
Description
Options
Returns
Example
Author
License
subroutine unix_to_date(unixtime,dat,ierr)
real(kind=realtime),intent(in) :: unixtime integer,intent(out) :: dat(8) integer,intent(out) :: ierr
Converts a Unix Epoch Time (UET) to a DAT date-time array.
unixtime The "Unix Epoch" time, or the number of seconds since 00:00:00 on January 1st, 1970, UTC; of type real(kind=realtime).
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]
ierr | Error code. If 0 no error occurred. |
Sample program:
program demo_unix_to_date use M_time, only : unix_to_date, u2d, fmtdate, realtime implicit none integer,parameter :: dp=kind(0.0d0) real(kind=realtime) :: unixtime ! seconds in a day real(kind=realtime),parameter :: DAY=86400.0_dp integer :: dat(8) integer :: ierr ! sample Unix Epoch time unixtime=1468939038.4639933_dp ! create DAT array for today call unix_to_date(unixtime,dat,ierr) write(*,*)Sample Date=,fmtdate(dat) ! go back one day call unix_to_date(unixtime-DAY,dat,ierr) ! subtract day and print write(*,*)Day Before =,fmtdate(dat) ! go forward one day call unix_to_date(unixtime+DAY,dat,ierr) ! add day print write(*,*)Day After =,fmtdate(dat) end program demo_unix_to_dateResults:
Sample Date=Tuesday, July 19th, 2016 10:37:18 AM Day Before =Monday, July 18th, 2016 10:37:18 AM Day After =Wednesday, July 20th, 2016 10:37:18 AM
John S. Urban, 2015
Nemo Release 3.1 | unix_to_date (3) | February 23, 2025 |