| | 256 | |
| | 257 | * Convert between the UNIX time in the .cpm table to Julian Date |
| | 258 | {{{ |
| | 259 | ;+ |
| | 260 | ; PURPOSE: |
| | 261 | ; Convert linux time (the number of seconds since UTC Jan 1 1970) to |
| | 262 | ; julian date (the number of days since Jan 1 4713 BC). |
| | 263 | ; |
| | 264 | ; CATEGORY: |
| | 265 | ; time |
| | 266 | ; |
| | 267 | ; CALLING SEQUENCE: |
| | 268 | ; result = linux2jd(linuxTime) |
| | 269 | ; |
| | 270 | ; INPUT: |
| | 271 | ; The linuxTime, in seconds |
| | 272 | ; |
| | 273 | ; OUTPUT: |
| | 274 | ; The julian date, in days |
| | 275 | ; |
| | 276 | ; MODIFICATION HISTORY: |
| | 277 | ; March 2009 Written by Chris Beaumont |
| | 278 | ; April 8 2009: Fixed bug which treated j2000 as j2001 |
| | 279 | ;- |
| | 280 | function linux2jd, linuxTime |
| | 281 | compile_opt idl2 |
| | 282 | on_error, 2 |
| | 283 | |
| | 284 | ;- check inputs |
| | 285 | if n_params() ne 1 then begin |
| | 286 | print, 'linux2jd calling sequence:' |
| | 287 | print, ' jd = linux2jd(linux time)' |
| | 288 | return, !values.f_nan |
| | 289 | endif |
| | 290 | |
| | 291 | ;- reference numbers |
| | 292 | j2000 = 946684800D ;-linux time at 2000 |
| | 293 | juldate, [2000,1,1], jd0 ;-reduced julian date at 2000 |
| | 294 | jd0 += 2400000D ;-conversion to normal jd |
| | 295 | |
| | 296 | return, jd0 + (linuxTime - j2000) / 86400 |
| | 297 | end |
| | 298 | |
| | 299 | }}} |