?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE SCL Interpreter : Date Time Functions' ??
MODULE clm$date_time_functions;

{
{ PURPOSE:
{   This module contains the functions that concern date and time.
{

?? NEWTITLE := 'Global Declarations', EJECT ??
?? PUSH (LISTEXT := ON) ??
*copyc clc$compiling_for_test_harness
*copyc cle$work_area_overflow
?? POP ??

*copyc clp$convert_date_time_to_string
*copyc clp$convert_string_to_date_time
*copyc clp$get_time_zone_identifier
*copyc clp$make_date_time_value
*copyc clp$make_string_value
*copyc clp$make_time_zone_value
*copyc clp$evaluate_parameters
*copyc osp$set_status_abnormal
*copyc pmp$compute_local_date_time
*copyc pmp$compute_universal_date_time
*copyc pmp$get_compact_date_time
*copyc pmp$get_time_zone

?? TITLE := 'clp$$date', EJECT ??

  PROCEDURE [XDCL] clp$$date
    (    parameter_list: clt$parameter_list;
     VAR work_area {input, output} : ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);

{ FUNCTION (osm$$date) $date (
{   format: any of
{       key
{         default
{         dmy
{         (isod, iso)
{         mdy
{         month
{         ordinal
{       keyend
{       string
{     anyend = default
{   date: date = $now
{   )

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 2] of clt$pdt_parameter_name,
        parameters: array [1 .. 2] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$union_type_qualifier,
          type_size_1: clt$type_specification_size,
          element_type_spec_1: record
            header: clt$type_specification_header,
            qualifier: clt$keyword_type_qualifier,
            keyword_specs: array [1 .. 7] of clt$keyword_specification,
          recend,
          type_size_2: clt$type_specification_size,
          element_type_spec_2: record
            header: clt$type_specification_header,
            qualifier: clt$string_type_qualifier,
          recend,
          default_value: string (7),
        recend,
        type2: record
          header: clt$type_specification_header,
          qualifier: clt$date_time_type_qualifier,
          default_value: string (4),
        recend,
      recend := [[1, [88, 1, 20, 9, 6, 26, 671], clc$function, 2, 2, 0, 0, 0, 0, 0, 'OSM$$DATE'],
            [['DATE                           ', clc$nominal_entry, 2],
            ['FORMAT                         ', clc$nominal_entry, 1]], [
{ PARAMETER 1
      [2, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 294, clc$optional_default_parameter, 0,
            7],
{ PARAMETER 2
      [1, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 5, clc$optional_default_parameter, 0,
            4]],
{ PARAMETER 1
      [[1, 0, clc$union_type], [[clc$keyword_type, clc$string_type], FALSE, 2], 266,
            [[1, 0, clc$keyword_type], [7], [['DEFAULT                        ', clc$nominal_entry,
            clc$normal_usage_entry, 1], ['DMY                            ', clc$nominal_entry,
            clc$normal_usage_entry, 2], ['ISO                            ', clc$abbreviation_entry,
            clc$normal_usage_entry, 3], ['ISOD                           ', clc$nominal_entry,
            clc$normal_usage_entry, 3], ['MDY                            ', clc$nominal_entry,
            clc$normal_usage_entry, 4], ['MONTH                          ', clc$nominal_entry,
            clc$normal_usage_entry, 5], ['ORDINAL                        ', clc$nominal_entry,
            clc$normal_usage_entry, 6]]], 8, [[1, 0, clc$string_type], [0, clc$max_string_size, FALSE]],
            'default'],
{ PARAMETER 2
      [[1, 0, clc$date_time_type], [$clt$date_and_or_time [clc$date], $clt$date_time_tenses
            [clc$past, clc$present, clc$future]], '$now']];

?? POP ??

    CONST
      p$format = 1,
      p$date = 2;

    VAR
      pvt: array [1 .. 2] of clt$parameter_value;

    VAR
      date_string: ost$string,
      format: string (clc$max_date_time_form_string);

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$format].value^.kind = clc$keyword THEN
      IF pvt [p$format].value^.keyword_value = 'DEFAULT' THEN
        format := '';
      ELSE
        format := pvt [p$format].value^.keyword_value;
      IFEND;
    ELSE
      format := pvt [p$format].value^.string_value^;
    IFEND;

    clp$convert_date_time_to_string (pvt [p$date].value^.date_time_value, format, date_string, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    clp$make_string_value (date_string.value (1, date_string.size), work_area, result);
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
    IFEND;

  PROCEND clp$$date;
?? TITLE := 'clp$$date_time', EJECT ??

  PROCEDURE [XDCL] clp$$date_time
    (    parameter_list: clt$parameter_list;
     VAR work_area {input, output} : ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);

{ FUNCTION (osm$$date_time) $date_time (
{   string: string = $required
{   format: string = $optional
{   )

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 2] of clt$pdt_parameter_name,
        parameters: array [1 .. 2] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$string_type_qualifier,
        recend,
        type2: record
          header: clt$type_specification_header,
          qualifier: clt$string_type_qualifier,
        recend,
      recend := [[1, [87, 12, 11, 12, 6, 2, 357], clc$function, 2, 2, 1, 0, 0, 0, 0, 'OSM$$DATE_TIME'],
            [['FORMAT                         ', clc$nominal_entry, 2],
            ['STRING                         ', clc$nominal_entry, 1]], [
{ PARAMETER 1
      [2, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 8, clc$required_parameter, 0, 0],
{ PARAMETER 2
      [1, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 8, clc$optional_parameter, 0, 0]],
{ PARAMETER 1
      [[1, 0, clc$string_type], [0, clc$max_string_size, FALSE]],
{ PARAMETER 2
      [[1, 0, clc$string_type], [0, clc$max_string_size, FALSE]]];

?? POP ??

    CONST
      p$string = 1,
      p$format = 2;

    VAR
      pvt: array [1 .. 2] of clt$parameter_value;

    VAR
      date_time: clt$date_time,
      format: string (clc$max_date_time_form_string);

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$format].value <> NIL THEN
      format := pvt [p$format].value^.string_value^;
    ELSE
      format := '';
    IFEND;
    clp$convert_string_to_date_time (pvt [p$string].value^.string_value^, format, date_time, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    clp$make_date_time_value (date_time, work_area, result);
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
    IFEND;

  PROCEND clp$$date_time;
?? TITLE := 'clp$$date_time_string', EJECT ??

  PROCEDURE [XDCL] clp$$date_time_string
    (    parameter_list: clt$parameter_list;
     VAR work_area {input, output} : ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);

{ FUNCTION (osm$$datts) $date_time_string (
{   format: any of
{       key
{         default, ampm, dmy, hms
{         (isod, iso)
{         isot, mdy
{         (millisecond, ms)
{         month, ordinal
{       keyend
{       string
{     anyend = default
{   date_time: date_time = $now
{   )

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 2] of clt$pdt_parameter_name,
        parameters: array [1 .. 2] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$union_type_qualifier,
          type_size_1: clt$type_specification_size,
          element_type_spec_1: record
            header: clt$type_specification_header,
            qualifier: clt$keyword_type_qualifier,
            keyword_specs: array [1 .. 12] of clt$keyword_specification,
          recend,
          type_size_2: clt$type_specification_size,
          element_type_spec_2: record
            header: clt$type_specification_header,
            qualifier: clt$string_type_qualifier,
          recend,
          default_value: string (7),
        recend,
        type2: record
          header: clt$type_specification_header,
          qualifier: clt$date_time_type_qualifier,
          default_value: string (4),
        recend,
      recend := [[1, [88, 9, 23, 13, 41, 12, 733], clc$function, 2, 2, 0, 0, 0, 0, 0, 'OSM$$DATTS'],
            [['DATE_TIME                      ', clc$nominal_entry, 2],
            ['FORMAT                         ', clc$nominal_entry, 1]], [
{ PARAMETER 1
      [2, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 479, clc$optional_default_parameter, 0,
            7],
{ PARAMETER 2
      [1, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 5, clc$optional_default_parameter, 0,
            4]],
{ PARAMETER 1
      [[1, 0, clc$union_type], [[clc$keyword_type, clc$string_type], FALSE, 2], 451,
            [[1, 0, clc$keyword_type], [12], [['AMPM                           ', clc$nominal_entry,
            clc$normal_usage_entry, 2], ['DEFAULT                        ', clc$nominal_entry,
            clc$normal_usage_entry, 1], ['DMY                            ', clc$nominal_entry,
            clc$normal_usage_entry, 3], ['HMS                            ', clc$nominal_entry,
            clc$normal_usage_entry, 4], ['ISO                            ', clc$abbreviation_entry,
            clc$normal_usage_entry, 5], ['ISOD                           ', clc$nominal_entry,
            clc$normal_usage_entry, 5], ['ISOT                           ', clc$nominal_entry,
            clc$normal_usage_entry, 6], ['MDY                            ', clc$nominal_entry,
            clc$normal_usage_entry, 7], ['MILLISECOND                    ', clc$nominal_entry,
            clc$normal_usage_entry, 8], ['MONTH                          ', clc$nominal_entry,
            clc$normal_usage_entry, 9], ['MS                             ', clc$abbreviation_entry,
            clc$normal_usage_entry, 8], ['ORDINAL                        ', clc$nominal_entry,
            clc$normal_usage_entry, 10]]], 8, [[1, 0, clc$string_type], [0, clc$max_string_size, FALSE]],
            'default'],
{ PARAMETER 2
      [[1, 0, clc$date_time_type], [$clt$date_and_or_time [clc$date, clc$time],
            $clt$date_time_tenses [clc$past, clc$present, clc$future]], '$now']];

?? POP ??

    CONST
      p$format = 1,
      p$date_time = 2;

    VAR
      pvt: array [1 .. 2] of clt$parameter_value;

    VAR
      format: string (clc$max_date_time_form_string),
      date_time_string: ost$string;


    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$format].value^.kind = clc$keyword THEN
      IF pvt [p$format].value^.keyword_value = 'DEFAULT' THEN
        format := '';
      ELSE
        format := pvt [p$format].value^.keyword_value;
      IFEND;
    ELSE
      format := pvt [p$format].value^.string_value^;
    IFEND;

    clp$convert_date_time_to_string (pvt [p$date_time].value^.date_time_value, format, date_time_string,
          status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    clp$make_string_value (date_time_string.value (1, date_time_string.size), work_area, result);
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
    IFEND;

  PROCEND clp$$date_time_string;
?? TITLE := 'clp$$day', EJECT ??

  PROCEDURE [XDCL] clp$$day
    (    parameter_list: clt$parameter_list;
     VAR work_area {input, output} : ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);

{ FUNCTION (osm$$day) $day (
{   format: any of
{       key
{         (full, dn, f)
{         (brief, da, b)
{       keyend
{       string
{     anyend = full
{   date: date = $now
{   )

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 2] of clt$pdt_parameter_name,
        parameters: array [1 .. 2] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$union_type_qualifier,
          type_size_1: clt$type_specification_size,
          element_type_spec_1: record
            header: clt$type_specification_header,
            qualifier: clt$keyword_type_qualifier,
            keyword_specs: array [1 .. 6] of clt$keyword_specification,
          recend,
          type_size_2: clt$type_specification_size,
          element_type_spec_2: record
            header: clt$type_specification_header,
            qualifier: clt$string_type_qualifier,
          recend,
          default_value: string (4),
        recend,
        type2: record
          header: clt$type_specification_header,
          qualifier: clt$date_time_type_qualifier,
          default_value: string (4),
        recend,
      recend := [[1, [87, 12, 11, 12, 6, 22, 534], clc$function, 2, 2, 0, 0, 0, 0, 0, 'OSM$$DAY'],
            [['DATE                           ', clc$nominal_entry, 2],
            ['FORMAT                         ', clc$nominal_entry, 1]], [
{ PARAMETER 1
      [2, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 257, clc$optional_default_parameter, 0,
            4],
{ PARAMETER 2
      [1, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 5, clc$optional_default_parameter, 0,
            4]],
{ PARAMETER 1
      [[1, 0, clc$union_type], [[clc$keyword_type, clc$string_type], FALSE, 2], 229,
            [[1, 0, clc$keyword_type], [6], [['B                              ', clc$abbreviation_entry,
            clc$normal_usage_entry, 2], ['BRIEF                          ', clc$nominal_entry,
            clc$normal_usage_entry, 2], ['DA                             ', clc$alias_entry,
            clc$normal_usage_entry, 2], ['DN                             ', clc$alias_entry,
            clc$normal_usage_entry, 1], ['F                              ', clc$abbreviation_entry,
            clc$normal_usage_entry, 1], ['FULL                           ', clc$nominal_entry,
            clc$normal_usage_entry, 1]]], 8, [[1, 0, clc$string_type], [0, clc$max_string_size, FALSE]],
            'full'],
{ PARAMETER 2
      [[1, 0, clc$date_time_type], [$clt$date_and_or_time [clc$date], $clt$date_time_tenses
            [clc$past, clc$present, clc$future]], '$now']];

?? POP ??

    CONST
      p$format = 1,
      p$date = 2;

    VAR
      pvt: array [1 .. 2] of clt$parameter_value;

    VAR
      day_string: ost$string,
      format: string (clc$max_date_time_form_string);


    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$format].value^.kind = clc$string THEN
      format := pvt [p$format].value^.string_value^;
    ELSEIF pvt [p$format].value^.keyword_value = 'FULL' THEN
      format := 'DN';
    ELSE
      format := 'DA';
    IFEND;

    clp$convert_date_time_to_string (pvt [p$date].value^.date_time_value, format, day_string, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    clp$make_string_value (day_string.value (1, day_string.size), work_area, result);
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
    IFEND;

  PROCEND clp$$day;
?? TITLE := 'clp$$local_date_time', EJECT ??

  PROCEDURE [XDCL] clp$$local_date_time
    (    parameter_list: clt$parameter_list;
     VAR work_area {input, output} : ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);



{ FUNCTION (osm$$local_date_time) $local_date_time (
{   universal_date_time: date_time = $required
{   time_zone: time_zone = $required
{   )

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 2] of clt$pdt_parameter_name,
        parameters: array [1 .. 2] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$date_time_type_qualifier,
        recend,
        type2: record
          header: clt$type_specification_header,
        recend,
      recend := [[1, [87, 12, 11, 12, 6, 41, 2], clc$function, 2, 2, 2, 0, 0, 0, 0, 'OSM$$LOCAL_DATE_TIME'],
            [['TIME_ZONE                      ', clc$nominal_entry, 2],
            ['UNIVERSAL_DATE_TIME            ', clc$nominal_entry, 1]], [
{ PARAMETER 1
      [2, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 5, clc$required_parameter, 0, 0],
{ PARAMETER 2
      [1, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$required_parameter, 0, 0]],
{ PARAMETER 1
      [[1, 0, clc$date_time_type], [$clt$date_and_or_time [clc$date, clc$time],
            $clt$date_time_tenses [clc$past, clc$present, clc$future]]],
{ PARAMETER 2
      [[1, 0, clc$time_zone_type]]];

?? POP ??

    CONST
      p$universal_date_time = 1,
      p$time_zone = 2;

    VAR
      local_date_time: clt$date_time,
      pvt: array [1 .. 2] of clt$parameter_value;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    pmp$compute_local_date_time (pvt [p$universal_date_time].value^.date_time_value.value,
          pvt [p$time_zone].value^.time_zone_value, local_date_time.value, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    local_date_time.time_specified := TRUE;
    local_date_time.date_specified := TRUE;

    clp$make_date_time_value (local_date_time, work_area, result);
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
    IFEND;

  PROCEND clp$$local_date_time;
?? TITLE := 'clp$$time', EJECT ??

  PROCEDURE [XDCL] clp$$time
    (    parameter_list: clt$parameter_list;
     VAR work_area {input, output} : ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);

{ FUNCTION (osm$$time) $time (
{   format: any of
{       key
{         default
{         ampm
{         hms
{         isot
{         (millisecond, ms)
{       keyend
{       string
{     anyend = default
{   time: time = $now
{   )

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 2] of clt$pdt_parameter_name,
        parameters: array [1 .. 2] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$union_type_qualifier,
          type_size_1: clt$type_specification_size,
          element_type_spec_1: record
            header: clt$type_specification_header,
            qualifier: clt$keyword_type_qualifier,
            keyword_specs: array [1 .. 6] of clt$keyword_specification,
          recend,
          type_size_2: clt$type_specification_size,
          element_type_spec_2: record
            header: clt$type_specification_header,
            qualifier: clt$string_type_qualifier,
          recend,
          default_value: string (7),
        recend,
        type2: record
          header: clt$type_specification_header,
          qualifier: clt$date_time_type_qualifier,
          default_value: string (4),
        recend,
      recend := [[1, [88, 1, 20, 9, 11, 22, 567], clc$function, 2, 2, 0, 0, 0, 0, 0, 'OSM$$TIME'],
            [['FORMAT                         ', clc$nominal_entry, 1],
            ['TIME                           ', clc$nominal_entry, 2]], [
{ PARAMETER 1
      [1, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 257, clc$optional_default_parameter, 0,
            7],
{ PARAMETER 2
      [2, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 5, clc$optional_default_parameter, 0,
            4]],
{ PARAMETER 1
      [[1, 0, clc$union_type], [[clc$keyword_type, clc$string_type], FALSE, 2], 229,
            [[1, 0, clc$keyword_type], [6], [['AMPM                           ', clc$nominal_entry,
            clc$normal_usage_entry, 2], ['DEFAULT                        ', clc$nominal_entry,
            clc$normal_usage_entry, 1], ['HMS                            ', clc$nominal_entry,
            clc$normal_usage_entry, 3], ['ISOT                           ', clc$nominal_entry,
            clc$normal_usage_entry, 4], ['MILLISECOND                    ', clc$nominal_entry,
            clc$normal_usage_entry, 5], ['MS                             ', clc$abbreviation_entry,
            clc$normal_usage_entry, 5]]], 8, [[1, 0, clc$string_type], [0, clc$max_string_size, FALSE]],
            'default'],
{ PARAMETER 2
      [[1, 0, clc$date_time_type], [$clt$date_and_or_time [clc$time], $clt$date_time_tenses
            [clc$past, clc$present, clc$future]], '$now']];

?? POP ??

    CONST
      p$format = 1,
      p$time = 2;

    VAR
      pvt: array [1 .. 2] of clt$parameter_value;

    VAR
      format: string (clc$max_date_time_form_string),
      time_string: ost$string;


    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$format].value^.kind = clc$keyword THEN
      IF pvt [p$format].value^.keyword_value = 'DEFAULT' THEN
        format := '';
      ELSE
        format := pvt [p$format].value^.keyword_value;
      IFEND;
    ELSE
      format := pvt [p$format].value^.string_value^;
    IFEND;

    clp$convert_date_time_to_string (pvt [p$time].value^.date_time_value, format, time_string, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;
    clp$make_string_value (time_string.value (1, time_string.size), work_area, result);
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
    IFEND;

  PROCEND clp$$time;
?? TITLE := 'clp$$time_zone', EJECT ??

  PROCEDURE [XDCL] clp$$time_zone
    (    parameter_list: clt$parameter_list;
     VAR work_area {input, output} : ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);

{ FUNCTION (osm$$time_zone) $time_zone ()

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
      recend := [[1, [87, 11, 9, 15, 22, 7, 434], clc$function, 0, 0, 0, 0, 0, 0, 0, 'OSM$$TIME_ZONE']];

?? POP ??

    VAR
      time_zone: ost$time_zone;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, NIL, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    pmp$get_time_zone (time_zone, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    clp$make_time_zone_value (time_zone, work_area, result);
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
    IFEND;

  PROCEND clp$$time_zone;
?? TITLE := 'clp$$time_zone_identifier', EJECT ??

  PROCEDURE [XDCL] clp$$time_zone_identifier
    (    parameter_list: clt$parameter_list;
     VAR work_area {input, output} : ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);


{ FUNCTION (osm$$timzi) $time_zone_identifier, $time_zone_id (
{   format: any of
{       key
{         (full, tz, f)
{         (brief, tza, b)
{       keyend
{       string
{     anyend = full
{   time_zone: time_zone = $time_zone
{   )

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 2] of clt$pdt_parameter_name,
        parameters: array [1 .. 2] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$union_type_qualifier,
          type_size_1: clt$type_specification_size,
          element_type_spec_1: record
            header: clt$type_specification_header,
            qualifier: clt$keyword_type_qualifier,
            keyword_specs: array [1 .. 6] of clt$keyword_specification,
          recend,
          type_size_2: clt$type_specification_size,
          element_type_spec_2: record
            header: clt$type_specification_header,
            qualifier: clt$string_type_qualifier,
          recend,
          default_value: string (4),
        recend,
        type2: record
          header: clt$type_specification_header,
          default_value: string (10),
        recend,
      recend := [[1, [88, 9, 23, 13, 42, 11, 887], clc$function, 2, 2, 0, 0, 0, 0, 0, 'OSM$$TIMZI'],
            [['FORMAT                         ', clc$nominal_entry, 1],
            ['TIME_ZONE                      ', clc$nominal_entry, 2]], [
{ PARAMETER 1
      [1, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 257, clc$optional_default_parameter, 0,
            4],
{ PARAMETER 2
      [2, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$optional_default_parameter, 0,
            10]],
{ PARAMETER 1
      [[1, 0, clc$union_type], [[clc$keyword_type, clc$string_type], FALSE, 2], 229,
            [[1, 0, clc$keyword_type], [6], [['B                              ', clc$abbreviation_entry,
            clc$normal_usage_entry, 2], ['BRIEF                          ', clc$nominal_entry,
            clc$normal_usage_entry, 2], ['F                              ', clc$abbreviation_entry,
            clc$normal_usage_entry, 1], ['FULL                           ', clc$nominal_entry,
            clc$normal_usage_entry, 1], ['TZ                             ', clc$alias_entry,
            clc$normal_usage_entry, 1], ['TZA                            ', clc$alias_entry,
            clc$normal_usage_entry, 2]]], 8, [[1, 0, clc$string_type], [0, clc$max_string_size, FALSE]],
            'full'],
{ PARAMETER 2
      [[1, 0, clc$time_zone_type], '$time_zone']];

?? POP ??

    CONST
      p$format = 1,
      p$time_zone = 2;

    VAR
      pvt: array [1 .. 2] of clt$parameter_value;

    VAR
      date_time: clt$date_time,
      time_zone_ident: ost$string;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    IF pvt [p$format].value^.kind = clc$keyword THEN
      IF pvt [p$format].value^.keyword_value = 'FULL' THEN
        clp$get_time_zone_identifier (pvt [p$time_zone].value^.time_zone_value, TRUE, osc$null_name,
              time_zone_ident, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      ELSE {BRIEF}
        clp$get_time_zone_identifier (pvt [p$time_zone].value^.time_zone_value, FALSE, osc$null_name,
              time_zone_ident, status);
        IF NOT status.normal THEN
          RETURN;
        IFEND;
      IFEND;
    ELSE
      pmp$get_compact_date_time (date_time.value, status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
      date_time.time_specified := TRUE;
      date_time.date_specified := TRUE;
      clp$convert_date_time_to_string (date_time, pvt [p$format].value^.string_value^, time_zone_ident,
            status);
      IF NOT status.normal THEN
        RETURN;
      IFEND;
    IFEND;

    clp$make_string_value (time_zone_ident.value (1, time_zone_ident.size), work_area, result);
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
    IFEND;

  PROCEND clp$$time_zone_identifier;
?? TITLE := 'clp$$universal_date_time', EJECT ??

  PROCEDURE [XDCL] clp$$universal_date_time
    (    parameter_list: clt$parameter_list;
     VAR work_area {input, output} : ^clt$work_area;
     VAR result: ^clt$data_value;
     VAR status: ost$status);

{ FUNCTION (osm$$unidt) $universal_date_time (
{   local_date_time: date_time = $required
{   time_zone: time_zone = $required
{   )

?? PUSH (LISTEXT := ON) ??

    VAR
      pdt: [STATIC, READ, cls$declaration_section] record
        header: clt$pdt_header,
        names: array [1 .. 2] of clt$pdt_parameter_name,
        parameters: array [1 .. 2] of clt$pdt_parameter,
        type1: record
          header: clt$type_specification_header,
          qualifier: clt$date_time_type_qualifier,
        recend,
        type2: record
          header: clt$type_specification_header,
        recend,
      recend := [[1, [88, 9, 23, 13, 42, 47, 190], clc$function, 2, 2, 2, 0, 0, 0, 0, 'OSM$$UNIDT'],
            [['LOCAL_DATE_TIME                ', clc$nominal_entry, 1],
            ['TIME_ZONE                      ', clc$nominal_entry, 2]], [
{ PARAMETER 1
      [1, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 5, clc$required_parameter, 0, 0],
{ PARAMETER 2
      [2, clc$normal_usage_entry, clc$non_secure_parameter,
            $clt$parameter_spec_methods [clc$specify_positionally], clc$pass_by_value,
            clc$immediate_evaluation, clc$standard_parameter_checking, 3, clc$required_parameter, 0, 0]],
{ PARAMETER 1
      [[1, 0, clc$date_time_type], [$clt$date_and_or_time [clc$date, clc$time],
            $clt$date_time_tenses [clc$past, clc$present, clc$future]]],
{ PARAMETER 2
      [[1, 0, clc$time_zone_type]]];

?? POP ??

    CONST
      p$local_date_time = 1,
      p$time_zone = 2;

    VAR
      pvt: array [1 .. 2] of clt$parameter_value;

    VAR
      universal_date_time: clt$date_time;

    clp$evaluate_parameters (parameter_list, #SEQ (pdt), NIL, ^pvt, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    pmp$compute_universal_date_time (pvt [p$local_date_time].value^.date_time_value.value,
          pvt [p$time_zone].value^.time_zone_value, universal_date_time.value, status);
    IF NOT status.normal THEN
      RETURN;
    IFEND;

    universal_date_time.time_specified := TRUE;
    universal_date_time.date_specified := TRUE;

    clp$make_date_time_value (universal_date_time, work_area, result);
    IF result = NIL THEN
      osp$set_status_abnormal ('CL', cle$work_area_overflow, '', status);
    IFEND;

  PROCEND clp$$universal_date_time;

MODEND clm$date_time_functions;
