On Thursday, 5 November 2015 10:47:30 UTC-8, luc...@gmail.com wrote:
> Hello I have a problem and I am trying to see if IDL can solve this
>
> I have an initial date
> 08/05/2012 05:14:39
>
> and then my data is arrange in days and fractions of days
> DAY
> 9.77013 -> meaning 9.77013 days after the initial date
> 9.77037
> 9.77060
> 9.77083
> 9.77106
> 9.77130
> 9.77153
> 9.77175
> 9.77199
> 9.77222
> 9.77245
>
> is there a way that IDL can help me to convert each point to real date and time given the start date and time ?
>
>
> Thanks
This should do it.
d0Str = '08/05/2012 05:14:39'
;; Assuming mm/dd/yyyy: correct?
d0Jul = 0.0D ; Initialize to Double for millisecond accuracy
ReadS, d0Str, d0Jul, $
Format='(C(CMOI2,X,CDI2,X,CYI4,X,CHI2,X,CMI2,X,CSI2))'
dOffsets = [9.77013, 9.77037, 9.77060, 9.77083, 9.77106, 9.77130, 9.77153, $
9.77175, 9.77199, 9.77222, 9.77245]
dJuls = d0Jul + dOffsets
Print, [d0Jul, dJuls], $
Format='(C(CMOI2.2,"/",CDI2.2,"/",CYI4.4,X,CHI2.2,":",CMI2.2, ":",CSI2.2))'
For output, I get:
08/05/2012 05:14:39
08/14/2012 23:43:38
08/14/2012 23:43:58
08/14/2012 23:44:18
08/14/2012 23:44:38
08/14/2012 23:44:58
08/14/2012 23:45:19
08/14/2012 23:45:39
08/14/2012 23:45:58
08/14/2012 23:46:18
08/14/2012 23:46:38
08/14/2012 23:46:58
Those are truncated seconds, by the way. For more precision (which may be illusory):
Print, [d0Jul, dJuls], $
Format='(C(CMOI2.2,"/",CDI2.2,"/",CYI4.4,X,CHI2.2,":",CMI2.2, ":",CSF6.3))'
08/05/2012 05:14:39.000
08/14/2012 23:43:38.232
08/14/2012 23:43:58.968
08/14/2012 23:44:18.840
08/14/2012 23:44:38.712
08/14/2012 23:44:58.584
08/14/2012 23:45:19.320
08/14/2012 23:45:39.192
08/14/2012 23:45:58.200
08/14/2012 23:46:18.936
08/14/2012 23:46:38.808
08/14/2012 23:46:58.680
Dick Jackson Software Consulting Inc.
Victoria, BC, Canada --- http://www.d-jackson.com
|