[Info-vax] date comparison format from a program
Stephen Hoffman
seaohveh at hoffmanlabs.invalid
Mon May 20 11:20:01 EDT 2019
On 2019-05-20 13:27:49 +0000, gérard Calliet said:
> Is there a way to do from a compiled program (in C, for example)
> something as simple as done by the lexical f$cvtime with "comparison"
> parameter in DCL to get date strings which can easyly sorted? Pure VMS
> realm whished.
>
> (I have to write program examples in C with VMS dates format and
> associated routines and compare with RtlC usages).
If you really want to use text, use a text format based on ISO-8601.
For C, the standard C timekeeping API works correctly and allows for
comparisons (e.g. difftime), and there are routines available in the
dtss library that allow converting to (e.g.
utc_vmslocaltime,utc_vmslocaltime) and from (e.g. utc_mkvmslocaltime,
utc_mkvmsgmtime) OpenVMS native and epoch, and comparing (e.g,
utc_cmpintervaltime).
http://h30266.www3.hpe.com/odl/i64os/opsys/vmsos84/4493/4493pro_016.html#port_api
http://h30266.www3.hpe.com/odl/i64os/opsys/vmsos84/5763/5763profile_019.html#date_time_chap
if you must use RTL and system services, then use the "newer" UTC
system service and not the older $numtim and related calls.
http://h30266.www3.hpe.com/odl/axpos/opsys/vmsos84/5841/5841pro_075.html#sys_time_operations
Convert to UTC, and compare. Or use a C or dtss API that is timezone-aware.
For system services source code examples from C, see:
http://www.eight-cubed.com/examples.shtml
I'd expect to be able to get wrong answers with the older and
should-have-been-deprecated OpenVMS system service APIs including
$numtim, as they're not timezone and not DST-aware. The UTC system
services do better here.
--
Pure Personal Opinion | HoffmanLabs LLC
More information about the Info-vax
mailing list