C Library Functions  - u2d (3)

NAME

u2d(3f) - [M_time:UNIX_EPOCH] given Unix Epoch Time returns DAT date-time array (LICENSE:MIT)

CONTENTS

Synopsis
Description
Options
Returns
Example
Author
License

SYNOPSIS

function u2d(unixtime) result (dat)

    class(*),intent(in),optional      :: unixtime
    ! integer
    ! real
    ! real(kind=realtime)

integer :: dat(8)

DESCRIPTION

Given Unix Epoch Time returns DAT date-time array

OPTIONS

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.

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]

EXAMPLE

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_u2d

results:

    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

AUTHOR

John S. Urban, 2015

LICENSE

    MIT


Nemo Release 3.1 u2d (3) July 22, 2023
Generated by manServer 1.08 from ad4c5d4c-894b-47b3-8ec5-b26d75bcbed9 using man macros.