?? RIGHT := 110 ??
?? NEWTITLE := 'NOS/VE SCL : Module to provide interfaces needed by clm$date_time_conversion.' ??


MODULE clm$day_and_month_names_mgr;

{
{ PURPOSE:
{    This module contains the interface CLP$GET_DAY_AND_MONTH_NAMES and the
{ declaration of shared variable CLV$DAY_AND_MONTH_NAMES_LIST that are needed by
{ the date_time conversion routines.


?? NEWTITLE := 'Global declarations', EJECT ??

*IF NOT $true(osv$unix)
*copyc clp$find_help_module
*IFEND
*copyc clp$initialize_parse_state
*copyc clp$scan_lexical_unit
*IF NOT $true(osv$unix)
*copyc osp$find_parameter_prompt
*IFEND
*copyc osp$append_status_parameter
*copyc osp$set_status_abnormal
*copyc oss$task_shared
*copyc oss$job_paged_literal
*copyc osv$task_shared_heap


*copyc clt$day_and_month_names

?? PUSH (LISTEXT := ON) ??
*copyc cle$ecc_date_time_format
?? POP ??

  VAR
    clv$day_and_month_names_list: [XDCL, #GATE, oss$task_shared] ^clt$day_and_month_names :=
          ^clv$english_day_and_month_names;

  VAR
  clv$english_day_and_month_names: [XDCL, #GATE, READ, oss$job_paged_literal] clt$day_and_month_names := [NIL,
          'US_ENGLISH', [[7, 'January'], [8, 'February'], [5, 'March'], [5, 'April'], [3, 'May'], [4, 'June'],
          [4, 'July'], [6, 'August'], [9, 'September'], [7, 'October'], [8, 'November'], [8, 'December']],
          [[3, 'Jan'], [3, 'Feb'], [3, 'Mar'], [3, 'Apr'], [3, 'May'], [3, 'Jun'], [3, 'Jul'], [3, 'Aug'], [3,
          'Sep'], [3, 'Oct'], [3, 'Nov'], [3, 'Dec']], [[6, 'Monday'], [7, 'Tuesday'], [9, 'Wednesday'], [8,
          'Thursday'], [6, 'Friday'], [8, 'Saturday'], [6, 'Sunday']],
          [[3, 'Mon'], [3, 'Tue'], [3, 'Wed'], [3, 'Thu'], [3, 'Fri'], [3, 'Sat'], [3, 'Sun']]];


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

  PROCEDURE [XDCL, #GATE] clp$get_day_and_month_names
    (    language: ost$natural_language;
     VAR new_days_and_months_ptr: ^clt$day_and_month_names;
     VAR status: ost$status);

*IF NOT $true(osv$unix)
    VAR
      day_number: 1 .. 7,
      help_module: ^ost$help_module,
      ignore_online_manual: ost$online_manual_name,
      month_number: 1 .. 12,
      parameter_name: clt$parameter_name,
      parse: clt$parse_state,
      seed_name: pmt$program_name,
      temp_days_and_months_ptr: ^clt$day_and_month_names,
      template: ^ost$message_template;
*IFEND

    status.normal := TRUE;
*IF NOT $true(osv$unix)
    seed_name := 'MONTHS_AND_DAYS';

    clp$find_help_module (seed_name, language, help_module, ignore_online_manual, status);
    IF (NOT status.normal) OR (help_module = NIL) THEN
      osp$set_status_abnormal ('CL', cle$language_module_not_found, language, status);
      RETURN;
    IFEND;

    ALLOCATE temp_days_and_months_ptr IN osv$task_shared_heap^;

  /find_months_and_days/
    BEGIN
      temp_days_and_months_ptr^.language := language;
      temp_days_and_months_ptr^.next_entry := clv$day_and_month_names_list;

      FOR month_number := 1 TO 12 DO

        parameter_name := clv$english_day_and_month_names.months [month_number].value;
        osp$find_parameter_prompt (help_module, parameter_name, template, status);
        IF (NOT status.normal) OR (template = NIL) THEN
          EXIT /find_months_and_days/;
        IFEND;
        clp$initialize_parse_state (template, NIL, parse);
        clp$scan_lexical_unit (clc$slu_non_space, parse);
        IF parse.unit.kind <> clc$lex_name THEN
{Not a valid month template.}
          EXIT /find_months_and_days/;
        IFEND;
        temp_days_and_months_ptr^.months [month_number].value :=
              template^ (parse.unit_index, parse.unit.size);
        temp_days_and_months_ptr^.months [month_number].size := parse.unit.size;
        clp$scan_lexical_unit (clc$slu_non_space, parse);
        IF parse.unit.kind = clc$lex_comma THEN
          clp$scan_lexical_unit (clc$slu_non_space, parse);
          IF parse.unit.kind <> clc$lex_name THEN
{Not a valid month template.}
            EXIT /find_months_and_days/;
          IFEND;
          temp_days_and_months_ptr^.months_abbrev [month_number].
                value := template^ (parse.unit_index, parse.unit.size);
          temp_days_and_months_ptr^.months_abbrev [month_number].size := parse.unit.size;
          clp$scan_lexical_unit (clc$slu_non_space, parse);
        ELSE
          IF temp_days_and_months_ptr^.months [month_number].size < 3 THEN
            temp_days_and_months_ptr^.months_abbrev [month_number].
                  value := temp_days_and_months_ptr^.months [month_number].value;
            temp_days_and_months_ptr^.months_abbrev [month_number].
                  size := temp_days_and_months_ptr^.months [month_number].size;
          ELSE
            temp_days_and_months_ptr^.months_abbrev [month_number].
                  value := temp_days_and_months_ptr^.months [month_number].value (1, 3);
            temp_days_and_months_ptr^.months_abbrev [month_number].size := 3;
          IFEND;
        IFEND;
        IF parse.unit.kind <> clc$lex_end_of_line THEN
{Not a valid month template.}
          EXIT /find_months_and_days/;
        IFEND;
      FOREND;

      FOR day_number := 1 TO 7 DO

        parameter_name := clv$english_day_and_month_names.days [day_number].value;
        osp$find_parameter_prompt (help_module, parameter_name, template, status);
        IF (NOT status.normal) OR (template = NIL) THEN
          EXIT /find_months_and_days/;
        IFEND;
        clp$initialize_parse_state (template, NIL, parse);
        clp$scan_lexical_unit (clc$slu_non_space, parse);
        IF parse.unit.kind <> clc$lex_name THEN
          {Not a valid month template.}
          EXIT /find_months_and_days/;
        IFEND;
        temp_days_and_months_ptr^.days [day_number].value := template^ (parse.unit_index, parse.unit.size);
        temp_days_and_months_ptr^.days [day_number].size := parse.unit.size;
        clp$scan_lexical_unit (clc$slu_non_space, parse);
        IF parse.unit.kind = clc$lex_comma THEN
          clp$scan_lexical_unit (clc$slu_non_space, parse);
          IF parse.unit.kind <> clc$lex_name THEN
            {Not a valid month template.}
            EXIT /find_months_and_days/;
          IFEND;
          temp_days_and_months_ptr^.days_abbrev [day_number].
                value := template^ (parse.unit_index, parse.unit.size);
          temp_days_and_months_ptr^.days_abbrev [day_number].size := parse.unit.size;
          clp$scan_lexical_unit (clc$slu_non_space, parse);
        ELSE
          IF temp_days_and_months_ptr^.days [day_number].size < 3 THEN
            temp_days_and_months_ptr^.days_abbrev [day_number].
                  value := temp_days_and_months_ptr^.days [day_number].value;
            temp_days_and_months_ptr^.days_abbrev [day_number].
                  size := temp_days_and_months_ptr^.days [day_number].size;
          ELSE
            temp_days_and_months_ptr^.days_abbrev [day_number].
                  value := temp_days_and_months_ptr^.days [day_number].value (1, 3);
            temp_days_and_months_ptr^.days_abbrev [day_number].size := 3;
          IFEND;
        IFEND;
        IF parse.unit.kind <> clc$lex_end_of_line THEN
          {Not a valid month template.}
          EXIT /find_months_and_days/;
        IFEND;
      FOREND;

      new_days_and_months_ptr := temp_days_and_months_ptr;
      clv$day_and_month_names_list := new_days_and_months_ptr;
      RETURN;

    END /find_months_and_days/;

{If we get here, we could not find either day names or month names for the
{ specified language. English will be used.

    FREE temp_days_and_months_ptr IN osv$task_shared_heap^;
    osp$set_status_abnormal ('CL', cle$bad_template_for_month_day, parameter_name, status);
    osp$append_status_parameter (osc$status_parameter_delimiter, language, status);
*ELSE
    new_days_and_months_ptr := clv$day_and_month_names_list;
*IFEND

  PROCEND clp$get_day_and_month_names;

MODEND clm$day_and_month_names_mgr;
