[UP]


Manual Reference Pages  - unix_to_date (3)

NAME

unix_to_date(3f) - [M_time:UNIX_EPOCH] converts Unix Epoch Time to DAT date-time array (LICENSE:PD)

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
     real(kind=realtime)           :: unixtime
     ! seconds in a day
     real(kind=realtime),parameter :: DAY=86400.0d0
     integer                       :: dat(8)
     integer                       :: ierr
        ! sample Unix Epoch time
        unixtime=1468939038.4639933d0
        ! 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

Public Domain


unix_to_date (3) March 11, 2021
Generated by manServer 1.08 from e0bf4990-77d5-415d-bb1e-063645a1b71f using man macros.