C Library Functions - unix_to_date (3)
NAME
unix_to_date(3f) - [M_time:UNIX_EPOCH] converts Unix Epoch Time to
DAT date-time
array
(LICENSE:MIT)
CONTENTS
Synopsis
Description
Options
Returns
Example
Author
License
SYNOPSIS
subroutine unix_to_date(unixtime,dat,ierr)
real(kind=realtime),intent(in) :: unixtime
integer,intent(out) :: dat(8)
integer,intent(out) :: ierr
DESCRIPTION
Converts a Unix Epoch Time (UET) to a DAT date-time array.
OPTIONS
|
unixtime |
| |
The "Unix Epoch" time, or the number of seconds since
00:00:00 on January 1st, 1970, UTC; of type
real(kind=realtime).
|
|
RETURNS
|
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.
|
|
EXAMPLE
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_date
Results:
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
AUTHOR
John S. Urban, 2015
LICENSE
MIT
| Nemo Release 3.1 | unix_to_date (3) | June 29, 2025 |
Generated by manServer 1.08 from 0a8a1a1f-ceb2-4612-8a4c-b4640b7d5eb1 using man macros.