datetime2num


The datetime2num function returns the Julian Date from a string like '2005-09-28T04:35:14.45' or 2005-09-28T04:35:14.45. Strings with enclosing ' ' are present in FITS image headers and are returned using CImage:KwdGetRaw.

NOTE:

You may wish to test if the string is a time value before calling this function to avoid the ambiguous results for datetime2num("0000-00-00T00:00:00") and datetime2num(0).

Syntax

nJD = datetime2num( sString )

bullet.gif    sString is the target string.

bullet.gif    nJD is the Julian Date.

bullet.gif    On failure, 0.0 is returned.

Example

The scripts below return the Julian Date for several strings:

str = "'2005-09-28T04:35:14.45'"

-- date+time string with ' '

if is_datetime( str ) then

 

  nJD = datetime2num( str)

 

  Printf("JD = %.8f\n", nJD)

-- prints JD = 2453641.69113947

end

 

 

 

str = "2005-09-28T04:35:14.45"

-- date+time string without ' '

if is_datetime( str ) then

 

  nJD = datetime2num( str)

 

  Printf("JD = %.8f\n", nJD)

-- prints JD = 2453641.69113947

end

 

 

 

Printf("t = %.8f\n", datetime2num("Johnny"))

-- prints t = 0

Printf("t = %.8f\n", datetime2num(15.5))

-- prints t = 0

Related Topics

is_datetime

time2num

String Type Functions

 


Mira Pro x64 Script User's Guide, v.8.77 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.