An example to calculate seconds since midnight:
$ times="19:11:03"
$ h = f$integer(f$element(0,":",times))
$ m = f$integer(f$element(1,":",times))
$ s = f$integer(f$element(2,":",times))
$ seconds = (h*3600) + (m*60) + s
$ write sys$output h,":",m,":",s,"=",seconds$! date:
$ dates="1-JUN-2008"
$ dates = f$edit(dates,"UPCASE")
$ day=f$integer(f$cvtime(dates,"COMPARISON","DAY"))
$ mon=f$integer(f$cvtime(dates,"COMPARISON","MONTH"))
$ year=f$integer(f$cvtime(dates,"COMPARISON","YEAR"))
$ seconds=f$cvtime(dates,"COMPARISON","SECONDOFYEAR")
$ write sys$output dates,"=",day," ",mon," ",year,"=",seconds," sec"
Note: correct calculation of seconds since epoch is not easy to do in DCL, since You would have to take into account the leap-year algorithm.
A more appropriate way to write a small program in a higher level language: get the date string from the command-line, use the ascii-to-numeric time functions, then convert the resulting numerical time to a string, output the string in a DCL symbol.
See some examples in my VMS utilities page at
http://wwwvms.mppmu.mpg.de/~huber/u...
Look for the *time_t routines, and
$ h = f$integer(f$element(0,":",times))
$ m = f$integer(f$element(1,":",times))
$ s = f$integer(f$element(2,":",times))
$ seconds = (h*3600) + (m*60) + s
$ write sys$output h,":",m,":",s,"=",seconds
$! date:
$ dates="1-JUN-2008"
$ dates = f$edit(dates,"UPCASE")
$ day=f$integer(f$cvtime(dates,"COMPARISON","DAY"))
$ mon=f$integer(f$cvtime(dates,"COMPARISON","MONTH"))
$ year=f$integer(f$cvtime(dates,"COMPARISON","YEAR"))
$ seconds=f$cvtime(dates,"COMPARISON","SECONDOFYEAR")
$ write sys$output dates,"=",day," ",mon," ",year,"=",seconds," sec"
Note: correct calculation of seconds since epoch is not easy to do in DCL, since You would have to take into account the leap-year algorithm.
A more appropriate way to write a small program in a higher level language: get the date string from the command-line, use the ascii-to-numeric time functions, then convert the resulting numerical time to a string, output the string in a DCL symbol.
See some examples in my VMS utilities page at
http://wwwvms.mppmu.mpg.de/~huber/u...
Look for the *time_t routines, and vmstime_to_time_t_m.C in the main/ directory.