C Library Functions  - m2d (3)

NAME

m2d(3f) - [M_time:MODIFIED_JULIAN] given a MJD (Modified Julian Date) returns a date-time array DAT. (LICENSE:MIT)

CONTENTS

Synopsis
Description
Options
Returns
Example
Author
License

SYNOPSIS

function m2d(modified_julian) result(dat)

    real(kind=realtime),intent(in),optional :: modified_julian
    integer                                 :: dat(8)

DESCRIPTION

Converts a Modified Julian Date to a DAT date-time array.

OPTIONS

modified_juliandate
  A Modified Julian Date (MJD) measures days (and fractional days) since the start of 17 Nov 1858 CE in Universal Time (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_m2d
    use M_time, only : m2d, d2m, fmtdate, realtime
    implicit none
    integer,parameter   :: dp=kind(0.0d0)
    real(kind=realtime) :: today
    integer             :: dat(8)
       call date_and_time(values=dat) ! get the date using intrinsic
       today=d2m(dat)                  ! convert today to Julian Date
       write(*,*)’Today=’,fmtdate(m2d(today))
       ! math is easy with Julian Days and Julian Dates
       write(*,*)’Yesterday=’,fmtdate(m2d(today-1.0_dp))
       write(*,*)’Tomorrow=’,fmtdate(m2d(today+1.0_dp))
    end program demo_m2d

Results:

    >  Today=Sunday, January 26th, 2025 1:08:25 AM UTC-05:00
    >  Yesterday=Saturday, January 25th, 2025 1:08:25 AM UTC-05:00
    >  Tomorrow=Monday, January 27th, 2025 1:08:25 AM UTC-05:00

AUTHOR

John S. Urban, 2025

LICENSE

    MIT


Nemo Release 3.1 m2d (3) February 23, 2025
Generated by manServer 1.08 from 92d0f591-ffb6-4b20-b9cd-de77ad54a671 using man macros.