(LOGO.JPG) Python for OpenVMS

(go to: table of contents, index, list of vms_lib, prev: ATTACH, next: CREATE_DIR)


CONVERT_DATE_STRING - Convert Date String to Quadword


Format:
    status, context, date_time, defaulted_fields = \
        vms_lib.convert_date_string (date-string, [user-context], \
                         [flags], [defaults])
Returns:
status
condition code from LIB$CONVERT_DATE_STRING
context
Updated context value from the 'user-context' argument. If omitted this will be 'None'.
date_time
The converted time - 64-bit system time - a Python long integer.
See GENMAN 'Programming', 'special OpenVMS datatypes' for details.
defaulted-fields
Indicates which date or time fields have been defaulted. Bits are the same as those of the 'flags' argument.
Arguments:
date-string
The absolute date + time that is to be converted to the internal 64-bit format.
user-context
Translation context - usually set up by vms_lib.init_date_time_contexte.
flags
Specifies for which components might be omitted and defaults instead applied. See the 'OpenVMS RTL Library (LIB$) manual' for details.
defaults
Default values for omitted fields. This is a 7-item tuple of 16-bit values.
(year, month, day, hour, minute, second, hundredth)
Examples:
>>> import vms_lib
>>> import vms_sys

>>> status, context, date_time, defaulted_fields = \
...         vms_lib.convert_date_string('1-JUN-1999')
>>> print (status, context, date_time, defaulted_fields)
(1, None, 44349120000000000L, 120)
>>>

(the RTL manual explains why 120 is returned for defaulted_fields)

>>> print vms_sys.asctim (date_time)
 1-JUN-1999 00:00:00.00
>>>


>>> print vms_sys.asctim ()
 4-AUG-1999 20:23:11.62
>>> status, context, date_time, defaulted_fields = \
...         vms_lib.convert_date_string('YESTERDAY')
>>> print (status, context, date_time, defaulted_fields)
(1, None, 44403552000000000L, 0)
>>> print vms_sys.asctim (date_time)
 3-AUG-1999 00:00:00.00
>>>

>>> # German version
>>> context = 0
>>> import vms_libdtdef
>>> relative_day_name = "|gestern|heute|morgen|"
>>> context = vms_lib.init_date_time_context (context,
...           vms_libdtdef.LIB_K_RELATIVE_DAY_NAME, relative_day_name)
>>> status, context, date_time, defaulted_fields = \
...         vms_lib.convert_date_string ('morgen', context)
>>> print (status, context, date_time, defaulted_fields)
(1, 2755936, 44405280000000000L, 0)
>>> print vms_sys.asctim (date_time)
 5-AUG-1999 00:00:00.00
>>>


>>> vms_lib.convert_date_string('1-JUN')
Traceback (innermost last):
  File "<stdin>", line 1, in ?
vms_lib.error: (1410124, '%LIB-F-INCDATTIM, incomplete date-time,\
 missing fields with no defaults')
>>>


>>> status, context, date_time, defaulted_fields = \
...         vms_lib.convert_date_string('1-JUN', None, 0x7f, \
...         (1, 2, 3, 4, 5, 6, 7) )
Traceback (innermost last):
  File "<stdin>", line 3, in ?
vms_lib.error: (1410012, '%LIB-F-IVTIME, invalid time passed in,\
 or computed')
>>>

>>> status, context, date_time, defaulted_fields = \
...         vms_lib.convert_date_string('1-JUN', None, 0x7f, \
...         (1997, 2, 3, 4, 5, 6, 7) )
>>> print (status, context, date_time, defaulted_fields)
(1, None, 43718547060700000L, 121)
>>>
>>> print vms_sys.asctim (date_time)
 1-JUN-1997 04:05:06.07
>>>

(go to: table of contents, index, list of vms_lib, prev: ATTACH, next: CREATE_DIR)

04-AUG-1999 ZE.