comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: equivalent of c function: gmtime
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: equivalent of c function: gmtime [message #2328 is a reply to message #2319] Thu, 09 June 1994 02:02 Go to previous message
sjt is currently offline  sjt
Messages: 72
Registered: November 1993
Member
fitz@nextone.lanl.gov wrote:
: I understand that systime(arg) will return either the number of
: seconds elapsed from Jan 1, 1970 or a string with the current date
: and time. Does anyone know of procedures that are the equivalent
: of the C functions: gmtime, asctime, difftime, etc? In particular,
: given the seconds from Jan 1, 1970, is there a way to get a string
: giving the day, date, and time?

: ---
: Joe Fitzgerald
: MS D466
: Los Alamos National Laboratory
: Los Alamos, New Mexico 87545
: phone 505-667-1542
: fax 505-665-7395

THis isn't exactly what you need in that it works from 1950.0 rather than
1970, but that should be easy to change.

function invsec, stime

;+
; INVSEC
; This function converts seconds since 1950.0 into year,day,hour,min, and
; sec.
;
; Call:
; time = invsec(stime)
;
; Return value:
; time float 5-element array with year, day, hourm min, sec
;
; Argument:
; stime double Seconds since 00:00 UT on 1 Jan 1950 AD.
;
; History:
; Original, converted from Fortran: 11/11/91; SJT
;-


sc = stime mod 60.d0

sec = float(sc)

min = long(stime)/60
hour = min/60
min = min mod 60
day = hour/24
hour = hour mod 24
year = day/365 ; Warning this will not work after
; about 3400 or 3500 AD (when there
; have been 365 leap years).

day = (day mod 365) - (year+1)/4 ; Won't work after 2100
if (day lt 0) then begin
year = year - 1
day = day + 365 + ((year+2) mod 4 eq 0) ; Won't work after 2100
endif

day = day + 1
year = year + 1950

return, float([year, day, hour, min, sec])

end

--
James Tappin, School of Physics & Space Research
University of Birmingham
sjt@xun8.sr.bham.ac.uk
"If all else fails--read the instructions!"

O__
-- \/`
[Message index]
 
Read Message
Read Message
Previous Topic: Re: "Help" in Widget Programs
Next Topic: How to I get IDL postscript files from Sun to Mac

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 06:26:31 PDT 2025

Total time taken to generate the page: 1.11978 seconds