deprecated/buildtools/buildsystemtools/lib/Date/Manip.pm
author lorewang
Thu, 11 Nov 2010 11:26:32 +0800
changeset 677 44e49837144a
parent 655 3f65fd25dfd4
permissions -rw-r--r--
update release info
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
655
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     1
package Date::Manip;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     2
# Copyright (c) 1995-2003 Sullivan Beck.  All rights reserved.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     3
# This program is free software; you can redistribute it and/or modify it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     4
# under the same terms as Perl itself.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     5
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     6
###########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     7
###########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     8
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
     9
use vars qw($OS %Lang %Holiday %Events %Curr %Cnf %Zone $VERSION @ISA @EXPORT);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    10
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    11
# Determine the type of OS...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    12
$OS="Unix";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    13
$OS="Windows"  if ((defined $^O and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    14
                    $^O =~ /MSWin32/i ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    15
                    $^O =~ /Windows_95/i ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    16
                    $^O =~ /Windows_NT/i) ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    17
                   (defined $ENV{OS} and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    18
                    $ENV{OS} =~ /MSWin32/i ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    19
                    $ENV{OS} =~ /Windows_95/i ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    20
                    $ENV{OS} =~ /Windows_NT/i));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    21
$OS="Netware"  if (defined $^O and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    22
                   $^O =~ /NetWare/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    23
$OS="Mac"      if ((defined $^O and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    24
                    $^O =~ /MacOS/i) ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    25
                   (defined $ENV{OS} and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    26
                    $ENV{OS} =~ /MacOS/i));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    27
$OS="MPE"      if (defined $^O and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    28
                   $^O =~ /MPE/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    29
$OS="OS2"      if (defined $^O and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    30
                   $^O =~ /os2/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    31
$OS="VMS"      if (defined $^O and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    32
                   $^O =~ /VMS/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    33
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    34
# Determine if we're doing taint checking
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    35
$Date::Manip::NoTaint = eval { local $^W; unlink "$^X$^T"; 1 };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    36
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    37
###########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    38
# CUSTOMIZATION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    39
###########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    40
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    41
# See the section of the POD documentation section CUSTOMIZING DATE::MANIP
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    42
# below for a complete description of each of these variables.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    43
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    44
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    45
# Location of a the global config file.  Tilde (~) expansions are allowed.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    46
# This should be set in Date_Init arguments.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    47
$Cnf{"GlobalCnf"}="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    48
$Cnf{"IgnoreGlobalCnf"}="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    49
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    50
# Name of a personal config file and the path to search for it.  Tilde (~)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    51
# expansions are allowed.  This should be set in Date_Init arguments or in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    52
# the global config file.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    53
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    54
@Date::Manip::DatePath=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    55
if ($OS eq "Windows") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    56
  $Cnf{"PathSep"}         = ";";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    57
  $Cnf{"PersonalCnf"}     = "Manip.cnf";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    58
  $Cnf{"PersonalCnfPath"} = ".";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    59
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    60
} elsif ($OS eq "Netware") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    61
  $Cnf{"PathSep"}         = ";";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    62
  $Cnf{"PersonalCnf"}     = "Manip.cnf";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    63
  $Cnf{"PersonalCnfPath"} = ".";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    64
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    65
} elsif ($OS eq "MPE") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    66
  $Cnf{"PathSep"}         = ":";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    67
  $Cnf{"PersonalCnf"}     = "Manip.cnf";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    68
  $Cnf{"PersonalCnfPath"} = ".";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    69
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    70
} elsif ($OS eq "OS2") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    71
  $Cnf{"PathSep"}         = ":";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    72
  $Cnf{"PersonalCnf"}     = "Manip.cnf";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    73
  $Cnf{"PersonalCnfPath"} = ".";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    74
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    75
} elsif ($OS eq "Mac") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    76
  $Cnf{"PathSep"}         = ":";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    77
  $Cnf{"PersonalCnf"}     = "Manip.cnf";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    78
  $Cnf{"PersonalCnfPath"} = ".";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    79
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    80
} elsif ($OS eq "VMS") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    81
  # VMS doesn't like files starting with "."
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    82
  $Cnf{"PathSep"}         = "\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    83
  $Cnf{"PersonalCnf"}     = "Manip.cnf";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    84
  $Cnf{"PersonalCnfPath"} = ".\n~";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    85
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    86
} else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    87
  # Unix
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    88
  $Cnf{"PathSep"}         = ":";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    89
  $Cnf{"PersonalCnf"}     = ".DateManip.cnf";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    90
  $Cnf{"PersonalCnfPath"} = ".:~";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    91
  @Date::Manip::DatePath=qw(/bin /usr/bin /usr/local/bin);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    92
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    93
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    94
### Date::Manip variables set in the global or personal config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    95
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    96
# Which language to use when parsing dates.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    97
$Cnf{"Language"}="English";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    98
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
    99
# 12/10 = Dec 10 (US) or Oct 12 (anything else)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   100
$Cnf{"DateFormat"}="US";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   101
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   102
# Local timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   103
$Cnf{"TZ"}="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   104
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   105
# Timezone to work in (""=local, "IGNORE", or a timezone)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   106
$Cnf{"ConvTZ"}="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   107
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   108
# Date::Manip internal format (0=YYYYMMDDHH:MN:SS, 1=YYYYHHMMDDHHMNSS)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   109
$Cnf{"Internal"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   110
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   111
# First day of the week (1=monday, 7=sunday).  ISO 8601 says monday.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   112
$Cnf{"FirstDay"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   113
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   114
# First and last day of the work week  (1=monday, 7=sunday)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   115
$Cnf{"WorkWeekBeg"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   116
$Cnf{"WorkWeekEnd"}=5;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   117
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   118
# If non-nil, a work day is treated as 24 hours long (WorkDayBeg/WorkDayEnd
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   119
# ignored)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   120
$Cnf{"WorkDay24Hr"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   121
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   122
# Start and end time of the work day (any time format allowed, seconds
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   123
# ignored)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   124
$Cnf{"WorkDayBeg"}="08:00";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   125
$Cnf{"WorkDayEnd"}="17:00";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   126
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   127
# If "today" is a holiday, we look either to "tomorrow" or "yesterday" for
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   128
# the nearest business day.  By default, we'll always look "tomorrow"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   129
# first.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   130
$Cnf{"TomorrowFirst"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   131
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   132
# Erase the old holidays
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   133
$Cnf{"EraseHolidays"}="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   134
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   135
# Set this to non-zero to be produce completely backwards compatible deltas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   136
$Cnf{"DeltaSigns"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   137
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   138
# If this is 0, use the ISO 8601 standard that Jan 4 is in week 1.  If 1,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   139
# make week 1 contain Jan 1.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   140
$Cnf{"Jan1Week1"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   141
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   142
# 2 digit years fall into the 100 year period given by [ CURR-N,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   143
# CURR+(99-N) ] where N is 0-99.  Default behavior is 89, but other useful
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   144
# numbers might be 0 (forced to be this year or later) and 99 (forced to be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   145
# this year or earlier).  It can also be set to "c" (current century) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   146
# "cNN" (i.e.  c18 forces the year to bet 1800-1899).  Also accepts the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   147
# form cNNNN to give the 100 year period NNNN to NNNN+99.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   148
$Cnf{"YYtoYYYY"}=89;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   149
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   150
# Set this to 1 if you want a long-running script to always update the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   151
# timezone.  This will slow Date::Manip down.  Read the POD documentation.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   152
$Cnf{"UpdateCurrTZ"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   153
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   154
# Use an international character set.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   155
$Cnf{"IntCharSet"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   156
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   157
# Use this to force the current date to be set to this:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   158
$Cnf{"ForceDate"}="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   159
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   160
###########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   161
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   162
require 5.000;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   163
require Exporter;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   164
@ISA = qw(Exporter);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   165
@EXPORT = qw(
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   166
   DateManipVersion
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   167
   Date_Init
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   168
   ParseDateString
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   169
   ParseDate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   170
   ParseRecur
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   171
   Date_Cmp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   172
   DateCalc
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   173
   ParseDateDelta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   174
   UnixDate
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   175
   Delta_Format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   176
   Date_GetPrev
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   177
   Date_GetNext
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   178
   Date_SetTime
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   179
   Date_SetDateField
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   180
   Date_IsHoliday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   181
   Events_List
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   182
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   183
   Date_DaysInMonth
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   184
   Date_DayOfWeek
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   185
   Date_SecsSince1970
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   186
   Date_SecsSince1970GMT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   187
   Date_DaysSince1BC
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   188
   Date_DayOfYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   189
   Date_DaysInYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   190
   Date_WeekOfYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   191
   Date_LeapYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   192
   Date_DaySuffix
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   193
   Date_ConvTZ
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   194
   Date_TimeZone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   195
   Date_IsWorkDay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   196
   Date_NextWorkDay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   197
   Date_PrevWorkDay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   198
   Date_NearestWorkDay
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   199
   Date_NthDayOfYear
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   200
);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   201
use strict;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   202
use integer;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   203
use Carp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   204
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   205
use IO::File;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   206
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   207
$VERSION="5.42";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   208
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   209
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   210
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   211
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   212
$Curr{"InitLang"}      = 1;     # Whether a language is being init'ed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   213
$Curr{"InitDone"}      = 0;     # Whether Init_Date has been called
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   214
$Curr{"InitFilesRead"} = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   215
$Curr{"ResetWorkDay"}  = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   216
$Curr{"Debug"}         = "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   217
$Curr{"DebugVal"}      = "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   218
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   219
$Holiday{"year"}       = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   220
$Holiday{"dates"}      = {};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   221
$Holiday{"desc"}       = {};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   222
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   223
$Events{"raw"}         = [];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   224
$Events{"parsed"}      = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   225
$Events{"dates"}       = [];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   226
$Events{"recur"}       = [];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   227
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   228
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   229
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   230
# THESE ARE THE MAIN ROUTINES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   231
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   232
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   233
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   234
# Get rid of a problem with old versions of perl
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   235
no strict "vars";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   236
# This sorts from longest to shortest element
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   237
sub sortByLength {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   238
  return (length $b <=> length $a);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   239
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   240
use strict "vars";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   241
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   242
sub DateManipVersion {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   243
  print "DEBUG: DateManipVersion\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   244
  return $VERSION;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   245
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   246
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   247
sub Date_Init {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   248
  print "DEBUG: Date_Init\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   249
  $Curr{"Debug"}="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   250
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   251
  my(@args)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   252
  $Curr{"InitDone"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   253
  local($_)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   254
  my($internal,$firstday)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   255
  my($var,$val,$file,@tmp)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   256
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   257
  # InitFilesRead = 0    : no conf files read yet
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   258
  #                 1    : global read, no personal read
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   259
  #                 2    : personal read
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   260
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   261
  $Cnf{"EraseHolidays"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   262
  foreach (@args) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   263
    s/\s*$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   264
    s/^\s*//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   265
    /^(\S+) \s* = \s* (.+)$/x;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   266
    ($var,$val)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   267
    if ($var =~ /^GlobalCnf$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   268
      $Cnf{"GlobalCnf"}=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   269
      if ($val) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   270
        $Curr{"InitFilesRead"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   271
        &EraseHolidays();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   272
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   273
    } elsif ($var =~ /^PathSep$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   274
      $Cnf{"PathSep"}=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   275
    } elsif ($var =~ /^PersonalCnf$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   276
      $Cnf{"PersonalCnf"}=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   277
      $Curr{"InitFilesRead"}=1  if ($Curr{"InitFilesRead"}==2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   278
    } elsif ($var =~ /^PersonalCnfPath$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   279
      $Cnf{"PersonalCnfPath"}=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   280
      $Curr{"InitFilesRead"}=1  if ($Curr{"InitFilesRead"}==2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   281
    } elsif ($var =~ /^IgnoreGlobalCnf$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   282
      $Curr{"InitFilesRead"}=1  if ($Curr{"InitFilesRead"}==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   283
      $Cnf{"IgnoreGlobalCnf"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   284
    } elsif ($var =~ /^EraseHolidays$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   285
      &EraseHolidays();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   286
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   287
      push(@tmp,$_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   288
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   289
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   290
  @args=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   291
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   292
  # Read global config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   293
  if ($Curr{"InitFilesRead"}<1  &&  ! $Cnf{"IgnoreGlobalCnf"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   294
    $Curr{"InitFilesRead"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   295
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   296
    if ($Cnf{"GlobalCnf"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   297
      $file=&ExpandTilde($Cnf{"GlobalCnf"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   298
      &Date_InitFile($file)  if ($file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   299
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   300
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   301
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   302
  # Read personal config file
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   303
  if ($Curr{"InitFilesRead"}<2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   304
    $Curr{"InitFilesRead"}=2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   305
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   306
    if ($Cnf{"PersonalCnf"}  and  $Cnf{"PersonalCnfPath"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   307
      $file=&SearchPath($Cnf{"PersonalCnf"},$Cnf{"PersonalCnfPath"},"r");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   308
      &Date_InitFile($file)  if ($file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   309
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   310
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   311
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   312
  foreach (@args) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   313
    s/\s*$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   314
    s/^\s*//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   315
    /^(\S+) \s* = \s* (.*)$/x;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   316
    ($var,$val)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   317
    $val=""  if (! defined $val);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   318
    &Date_SetConfigVariable($var,$val);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   319
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   320
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   321
  confess "ERROR: Unknown FirstDay in Date::Manip.\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   322
    if (! &IsInt($Cnf{"FirstDay"},1,7));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   323
  confess "ERROR: Unknown WorkWeekBeg in Date::Manip.\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   324
    if (! &IsInt($Cnf{"WorkWeekBeg"},1,7));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   325
  confess "ERROR: Unknown WorkWeekEnd in Date::Manip.\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   326
    if (! &IsInt($Cnf{"WorkWeekEnd"},1,7));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   327
  confess "ERROR: Invalid WorkWeek in Date::Manip.\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   328
    if ($Cnf{"WorkWeekEnd"} <= $Cnf{"WorkWeekBeg"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   329
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   330
  my(%lang,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   331
     $tmp,%tmp,$tmp2,@tmp2,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   332
     $i,$j,@tmp3,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   333
     $zonesrfc,@zones)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   334
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   335
  my($L)=$Cnf{"Language"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   336
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   337
  if ($Curr{"InitLang"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   338
    $Curr{"InitLang"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   339
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   340
    if ($L eq "English") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   341
      &Date_Init_English(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   342
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   343
    } elsif ($L eq "French") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   344
      &Date_Init_French(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   345
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   346
    } elsif ($L eq "Swedish") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   347
      &Date_Init_Swedish(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   348
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   349
    } elsif ($L eq "German") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   350
      &Date_Init_German(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   351
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   352
    } elsif ($L eq "Polish") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   353
      &Date_Init_Polish(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   354
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   355
    } elsif ($L eq "Dutch"  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   356
             $L eq "Nederlands") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   357
      &Date_Init_Dutch(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   358
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   359
    } elsif ($L eq "Spanish") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   360
      &Date_Init_Spanish(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   361
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   362
    } elsif ($L eq "Portuguese") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   363
      &Date_Init_Portuguese(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   364
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   365
    } elsif ($L eq "Romanian") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   366
      &Date_Init_Romanian(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   367
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   368
    } elsif ($L eq "Italian") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   369
      &Date_Init_Italian(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   370
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   371
    } elsif ($L eq "Russian") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   372
      &Date_Init_Russian(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   373
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   374
    } elsif ($L eq "Turkish") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   375
      &Date_Init_Turkish(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   376
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   377
    } elsif ($L eq "Danish") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   378
      &Date_Init_Danish(\%lang);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   379
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   380
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   381
      confess "ERROR: Unknown language in Date::Manip.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   382
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   383
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   384
    #  variables for months
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   385
    #   Month   = "(jan|january|feb|february ... )"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   386
    #   MonL    = [ "Jan","Feb",... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   387
    #   MonthL  = [ "January","February", ... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   388
    #   MonthH  = { "january"=>1, "jan"=>1, ... }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   389
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   390
    $Lang{$L}{"MonthH"}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   391
    $Lang{$L}{"MonthL"}=[];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   392
    $Lang{$L}{"MonL"}=[];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   393
    &Date_InitLists([$lang{"month_name"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   394
                     $lang{"month_abb"}],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   395
                    \$Lang{$L}{"Month"},"lc,sort,back",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   396
                    [$Lang{$L}{"MonthL"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   397
                     $Lang{$L}{"MonL"}],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   398
                    [$Lang{$L}{"MonthH"},1]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   399
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   400
    #  variables for day of week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   401
    #   Week   = "(mon|monday|tue|tuesday ... )"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   402
    #   WL     = [ "M","T",... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   403
    #   WkL    = [ "Mon","Tue",... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   404
    #   WeekL  = [ "Monday","Tudesday",... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   405
    #   WeekH  = { "monday"=>1,"mon"=>1,"m"=>1,... }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   406
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   407
    $Lang{$L}{"WeekH"}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   408
    $Lang{$L}{"WeekL"}=[];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   409
    $Lang{$L}{"WkL"}=[];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   410
    $Lang{$L}{"WL"}=[];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   411
    &Date_InitLists([$lang{"day_name"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   412
                     $lang{"day_abb"}],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   413
                    \$Lang{$L}{"Week"},"lc,sort,back",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   414
                    [$Lang{$L}{"WeekL"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   415
                     $Lang{$L}{"WkL"}],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   416
                    [$Lang{$L}{"WeekH"},1]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   417
    &Date_InitLists([$lang{"day_char"}],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   418
                    "","lc",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   419
                    [$Lang{$L}{"WL"}],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   420
                    [\%tmp,1]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   421
    %{ $Lang{$L}{"WeekH"} } =
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   422
      (%{ $Lang{$L}{"WeekH"} },%tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   423
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   424
    #  variables for last
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   425
    #   Last      = "(last)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   426
    #   LastL     = [ "last" ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   427
    #   Each      = "(each)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   428
    #   EachL     = [ "each" ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   429
    #  variables for day of month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   430
    #   DoM       = "(1st|first ... 31st)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   431
    #   DoML      = [ "1st","2nd",... "31st" ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   432
    #   DoMH      = { "1st"=>1,"first"=>1, ... "31st"=>31 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   433
    #  variables for week of month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   434
    #   WoM       = "(1st|first| ... 5th|last)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   435
    #   WoMH      = { "1st"=>1, ... "5th"=>5,"last"=>-1 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   436
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   437
    $Lang{$L}{"LastL"}=$lang{"last"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   438
    &Date_InitStrings($lang{"last"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   439
                      \$Lang{$L}{"Last"},"lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   440
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   441
    $Lang{$L}{"EachL"}=$lang{"each"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   442
    &Date_InitStrings($lang{"each"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   443
                      \$Lang{$L}{"Each"},"lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   444
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   445
    $Lang{$L}{"DoMH"}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   446
    $Lang{$L}{"DoML"}=[];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   447
    &Date_InitLists([$lang{"num_suff"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   448
                     $lang{"num_word"}],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   449
                    \$Lang{$L}{"DoM"},"lc,sort,back,escape",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   450
                    [$Lang{$L}{"DoML"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   451
                     \@tmp],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   452
                    [$Lang{$L}{"DoMH"},1]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   453
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   454
    @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   455
    foreach $tmp (keys %{ $Lang{$L}{"DoMH"} }) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   456
      $tmp2=$Lang{$L}{"DoMH"}{$tmp};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   457
      if ($tmp2<6) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   458
        $Lang{$L}{"WoMH"}{$tmp} = $tmp2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   459
        push(@tmp,$tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   460
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   461
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   462
    foreach $tmp (@{ $Lang{$L}{"LastL"} }) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   463
      $Lang{$L}{"WoMH"}{$tmp} = -1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   464
      push(@tmp,$tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   465
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   466
    &Date_InitStrings(\@tmp,\$Lang{$L}{"WoM"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   467
                      "lc,sort,back,escape");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   468
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   469
    #  variables for AM or PM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   470
    #   AM      = "(am)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   471
    #   PM      = "(pm)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   472
    #   AmPm    = "(am|pm)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   473
    #   AMstr   = "AM"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   474
    #   PMstr   = "PM"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   475
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   476
    &Date_InitStrings($lang{"am"},\$Lang{$L}{"AM"},"lc,sort,escape");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   477
    &Date_InitStrings($lang{"pm"},\$Lang{$L}{"PM"},"lc,sort,escape");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   478
    &Date_InitStrings([ @{$lang{"am"}},@{$lang{"pm"}} ],\$Lang{$L}{"AmPm"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   479
                      "lc,back,sort,escape");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   480
    $Lang{$L}{"AMstr"}=$lang{"am"}[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   481
    $Lang{$L}{"PMstr"}=$lang{"pm"}[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   482
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   483
    #  variables for expressions used in parsing deltas
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   484
    #    Yabb   = "(?:y|yr|year|years)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   485
    #    Mabb   = similar for months
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   486
    #    Wabb   = similar for weeks
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   487
    #    Dabb   = similar for days
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   488
    #    Habb   = similar for hours
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   489
    #    MNabb  = similar for minutes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   490
    #    Sabb   = similar for seconds
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   491
    #    Repl   = { "abb"=>"replacement" }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   492
    # Whenever an abbreviation could potentially refer to two different
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   493
    # strings (M standing for Minutes or Months), the abbreviation must
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   494
    # be listed in Repl instead of in the appropriate Xabb values.  This
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   495
    # only applies to abbreviations which are substrings of other values
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   496
    # (so there is no confusion between Mn and Month).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   497
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   498
    &Date_InitStrings($lang{"years"}  ,\$Lang{$L}{"Yabb"}, "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   499
    &Date_InitStrings($lang{"months"} ,\$Lang{$L}{"Mabb"}, "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   500
    &Date_InitStrings($lang{"weeks"}  ,\$Lang{$L}{"Wabb"}, "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   501
    &Date_InitStrings($lang{"days"}   ,\$Lang{$L}{"Dabb"}, "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   502
    &Date_InitStrings($lang{"hours"}  ,\$Lang{$L}{"Habb"}, "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   503
    &Date_InitStrings($lang{"minutes"},\$Lang{$L}{"MNabb"},"lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   504
    &Date_InitStrings($lang{"seconds"},\$Lang{$L}{"Sabb"}, "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   505
    $Lang{$L}{"Repl"}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   506
    &Date_InitHash($lang{"replace"},undef,"lc",$Lang{$L}{"Repl"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   507
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   508
    #  variables for special dates that are offsets from now
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   509
    #    Now      = "(now|today)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   510
    #    Offset   = "(yesterday|tomorrow)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   511
    #    OffsetH  = { "yesterday"=>"-0:0:0:1:0:0:0",... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   512
    #    Times    = "(noon|midnight)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   513
    #    TimesH   = { "noon"=>"12:00:00","midnight"=>"00:00:00" }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   514
    #    SepHM    = hour/minute separator
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   515
    #    SepMS    = minute/second separator
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   516
    #    SepSS    = second/fraction separator
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   517
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   518
    $Lang{$L}{"TimesH"}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   519
    &Date_InitHash($lang{"times"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   520
                   \$Lang{$L}{"Times"},"lc,sort,back",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   521
                   $Lang{$L}{"TimesH"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   522
    &Date_InitStrings($lang{"now"},\$Lang{$L}{"Now"},"lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   523
    $Lang{$L}{"OffsetH"}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   524
    &Date_InitHash($lang{"offset"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   525
                   \$Lang{$L}{"Offset"},"lc,sort,back",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   526
                   $Lang{$L}{"OffsetH"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   527
    $Lang{$L}{"SepHM"}=$lang{"sephm"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   528
    $Lang{$L}{"SepMS"}=$lang{"sepms"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   529
    $Lang{$L}{"SepSS"}=$lang{"sepss"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   530
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   531
    #  variables for time zones
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   532
    #    zones      = regular expression with all zone names (EST)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   533
    #    n2o        = a hash of all parsable zone names with their offsets
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   534
    #    tzones     = reguar expression with all tzdata timezones (US/Eastern)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   535
    #    tz2z       = hash of all tzdata timezones to full timezone (EST#EDT)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   536
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   537
    $zonesrfc=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   538
      "idlw   -1200 ".  # International Date Line West
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   539
      "nt     -1100 ".  # Nome
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   540
      "hst    -1000 ".  # Hawaii Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   541
      "cat    -1000 ".  # Central Alaska
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   542
      "ahst   -1000 ".  # Alaska-Hawaii Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   543
      "akst   -0900 ".  # Alaska Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   544
      "yst    -0900 ".  # Yukon Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   545
      "hdt    -0900 ".  # Hawaii Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   546
      "akdt   -0800 ".  # Alaska Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   547
      "ydt    -0800 ".  # Yukon Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   548
      "pst    -0800 ".  # Pacific Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   549
      "pdt    -0700 ".  # Pacific Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   550
      "mst    -0700 ".  # Mountain Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   551
      "mdt    -0600 ".  # Mountain Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   552
      "cst    -0600 ".  # Central Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   553
      "cdt    -0500 ".  # Central Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   554
      "est    -0500 ".  # Eastern Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   555
      "act    -0500 ".  # Brazil, Acre
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   556
      "sat    -0400 ".  # Chile
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   557
      "bot    -0400 ".  # Bolivia
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   558
      "amt    -0400 ".  # Brazil, Amazon
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   559
      "acst   -0400 ".  # Brazil, Acre Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   560
      "edt    -0400 ".  # Eastern Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   561
      "ast    -0400 ".  # Atlantic Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   562
      #"nst   -0330 ".  # Newfoundland Standard      nst=North Sumatra    +0630
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   563
      "nft    -0330 ".  # Newfoundland
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   564
      #"gst   -0300 ".  # Greenland Standard         gst=Guam Standard    +1000
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   565
      #"bst   -0300 ".  # Brazil Standard            bst=British Summer   +0100
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   566
      "brt    -0300 ".  # Brazil Standard (official time)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   567
      "brst   -0300 ".  # Brazil Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   568
      "adt    -0300 ".  # Atlantic Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   569
      "art    -0300 ".  # Argentina
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   570
      "amst   -0300 ".  # Brazil, Amazon Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   571
      "ndt    -0230 ".  # Newfoundland Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   572
      "brst   -0200 ".  # Brazil Daylight (official time)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   573
      "fnt    -0200 ".  # Brazil, Fernando de Noronha
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   574
      "at     -0200 ".  # Azores
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   575
      "wat    -0100 ".  # West Africa
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   576
      "fnst   -0100 ".  # Brazil, Fernando de Noronha Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   577
      "gmt    +0000 ".  # Greenwich Mean
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   578
      "ut     +0000 ".  # Universal
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   579
      "utc    +0000 ".  # Universal (Coordinated)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   580
      "wet    +0000 ".  # Western European
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   581
      "cet    +0100 ".  # Central European
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   582
      "fwt    +0100 ".  # French Winter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   583
      "met    +0100 ".  # Middle European
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   584
      "mez    +0100 ".  # Middle European
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   585
      "mewt   +0100 ".  # Middle European Winter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   586
      "swt    +0100 ".  # Swedish Winter
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   587
      "bst    +0100 ".  # British Summer             bst=Brazil standard  -0300
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   588
      "gb     +0100 ".  # GMT with daylight savings
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   589
      "west   +0000 ".  # Western European Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   590
      "eet    +0200 ".  # Eastern Europe, USSR Zone 1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   591
      "cest   +0200 ".  # Central European Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   592
      "fst    +0200 ".  # French Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   593
      "ist    +0200 ".  # Israel standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   594
      "mest   +0200 ".  # Middle European Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   595
      "mesz   +0200 ".  # Middle European Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   596
      "metdst +0200 ".  # An alias for mest used by HP-UX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   597
      "sast   +0200 ".  # South African Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   598
      "sst    +0200 ".  # Swedish Summer             sst=South Sumatra    +0700
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   599
      "bt     +0300 ".  # Baghdad, USSR Zone 2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   600
      "eest   +0300 ".  # Eastern Europe Summer
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   601
      "eetedt +0300 ".  # Eastern Europe, USSR Zone 1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   602
      "idt    +0300 ".  # Israel Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   603
      "msk    +0300 ".  # Moscow
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   604
      "eat    +0300 ".  # East Africa
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   605
      "it     +0330 ".  # Iran
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   606
      "zp4    +0400 ".  # USSR Zone 3
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   607
      "msd    +0400 ".  # Moscow Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   608
      "zp5    +0500 ".  # USSR Zone 4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   609
      "ist    +0530 ".  # Indian Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   610
      "zp6    +0600 ".  # USSR Zone 5
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   611
      "novst  +0600 ".  # Novosibirsk time zone, Russia
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   612
      "nst    +0630 ".  # North Sumatra              nst=Newfoundland Std -0330
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   613
      #"sst   +0700 ".  # South Sumatra, USSR Zone 6 sst=Swedish Summer   +0200
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   614
      "javt   +0700 ".  # Java
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   615
      "hkt    +0800 ".  # Hong Kong
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   616
      "sgt    +0800 ".  # Singapore
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   617
      "cct    +0800 ".  # China Coast, USSR Zone 7
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   618
      "awst   +0800 ".  # Australian Western Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   619
      "wst    +0800 ".  # West Australian Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   620
      "pht    +0800 ".  # Asia Manila
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   621
      "kst    +0900 ".  # Republic of Korea
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   622
      "jst    +0900 ".  # Japan Standard, USSR Zone 8
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   623
      "rok    +0900 ".  # Republic of Korea
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   624
      "acst   +0930 ".  # Australian Central Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   625
      "cast   +0930 ".  # Central Australian Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   626
      "aest   +1000 ".  # Australian Eastern Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   627
      "east   +1000 ".  # Eastern Australian Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   628
      "gst    +1000 ".  # Guam Standard, USSR Zone 9 gst=Greenland Std    -0300
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   629
      "acdt   +1030 ".  # Australian Central Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   630
      "cadt   +1030 ".  # Central Australian Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   631
      "aedt   +1100 ".  # Australian Eastern Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   632
      "eadt   +1100 ".  # Eastern Australian Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   633
      "idle   +1200 ".  # International Date Line East
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   634
      "nzst   +1200 ".  # New Zealand Standard
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   635
      "nzt    +1200 ".  # New Zealand
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   636
      "nzdt   +1300 ".  # New Zealand Daylight
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   637
      "z +0000 ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   638
      "a +0100 b +0200 c +0300 d +0400 e +0500 f +0600 g +0700 h +0800 ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   639
      "i +0900 k +1000 l +1100 m +1200 ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   640
      "n -0100 o -0200 p -0300 q -0400 r -0500 s -0600 t -0700 u -0800 ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   641
      "v -0900 w -1000 x -1100 y -1200";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   642
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   643
    $Zone{"n2o"} = {};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   644
    ($Zone{"zones"},%{ $Zone{"n2o"} })=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   645
      &Date_Regexp($zonesrfc,"sort,lc,under,back",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   646
                   "keys");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   647
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   648
    $tmp=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   649
      "US/Pacific  PST8PDT ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   650
      "US/Mountain MST7MDT ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   651
      "US/Central  CST6CDT ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   652
      "US/Eastern  EST5EDT ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   653
      "Canada/Pacific  PST8PDT ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   654
      "Canada/Mountain MST7MDT ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   655
      "Canada/Central  CST6CDT ".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   656
      "Canada/Eastern  EST5EDT";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   657
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   658
    $Zone{"tz2z"} = {};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   659
    ($Zone{"tzones"},%{ $Zone{"tz2z"} })=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   660
      &Date_Regexp($tmp,"lc,under,back","keys");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   661
    $Cnf{"TZ"}=&Date_TimeZone;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   662
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   663
    #  misc. variables
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   664
    #    At     = "(?:at)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   665
    #    Of     = "(?:in|of)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   666
    #    On     = "(?:on)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   667
    #    Future = "(?:in)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   668
    #    Later  = "(?:later)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   669
    #    Past   = "(?:ago)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   670
    #    Next   = "(?:next)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   671
    #    Prev   = "(?:last|previous)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   672
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   673
    &Date_InitStrings($lang{"at"},    \$Lang{$L}{"At"},     "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   674
    &Date_InitStrings($lang{"on"},    \$Lang{$L}{"On"},     "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   675
    &Date_InitStrings($lang{"future"},\$Lang{$L}{"Future"}, "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   676
    &Date_InitStrings($lang{"later"}, \$Lang{$L}{"Later"},  "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   677
    &Date_InitStrings($lang{"past"},  \$Lang{$L}{"Past"},   "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   678
    &Date_InitStrings($lang{"next"},  \$Lang{$L}{"Next"},   "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   679
    &Date_InitStrings($lang{"prev"},  \$Lang{$L}{"Prev"},   "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   680
    &Date_InitStrings($lang{"of"},    \$Lang{$L}{"Of"},     "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   681
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   682
    #  calc mode variables
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   683
    #    Approx   = "(?:approximately)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   684
    #    Exact    = "(?:exactly)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   685
    #    Business = "(?:business)"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   686
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   687
    &Date_InitStrings($lang{"exact"},   \$Lang{$L}{"Exact"},   "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   688
    &Date_InitStrings($lang{"approx"},  \$Lang{$L}{"Approx"},  "lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   689
    &Date_InitStrings($lang{"business"},\$Lang{$L}{"Business"},"lc,sort");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   690
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   691
    ############### END OF LANGUAGE INITIALIZATION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   692
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   693
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   694
  if ($Curr{"ResetWorkDay"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   695
    my($h1,$m1,$h2,$m2)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   696
    if ($Cnf{"WorkDay24Hr"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   697
      ($Curr{"WDBh"},$Curr{"WDBm"})=(0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   698
      ($Curr{"WDEh"},$Curr{"WDEm"})=(24,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   699
      $Curr{"WDlen"}=24*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   700
      $Cnf{"WorkDayBeg"}="00:00";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   701
      $Cnf{"WorkDayEnd"}="23:59";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   702
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   703
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   704
      confess "ERROR: Invalid WorkDayBeg in Date::Manip.\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   705
        if (! (($h1,$m1)=&CheckTime($Cnf{"WorkDayBeg"})));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   706
      $Cnf{"WorkDayBeg"}="$h1:$m1";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   707
      confess "ERROR: Invalid WorkDayEnd in Date::Manip.\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   708
        if (! (($h2,$m2)=&CheckTime($Cnf{"WorkDayEnd"})));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   709
      $Cnf{"WorkDayEnd"}="$h2:$m2";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   710
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   711
      ($Curr{"WDBh"},$Curr{"WDBm"})=($h1,$m1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   712
      ($Curr{"WDEh"},$Curr{"WDEm"})=($h2,$m2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   713
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   714
      # Work day length = h1:m1  or  0:len (len minutes)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   715
      $h1=$h2-$h1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   716
      $m1=$m2-$m1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   717
      if ($m1<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   718
        $h1--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   719
        $m1+=60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   720
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   721
      $Curr{"WDlen"}=$h1*60+$m1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   722
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   723
    $Curr{"ResetWorkDay"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   724
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   725
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   726
  # current time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   727
  my($s,$mn,$h,$d,$m,$y,$wday,$yday,$isdst,$ampm,$wk)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   728
  if ($Cnf{"ForceDate"}=~
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   729
      /^(\d{4})-(\d{2})-(\d{2})-(\d{2}):(\d{2}):(\d{2})$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   730
       ($y,$m,$d,$h,$mn,$s)=($1,$2,$3,$4,$5,$6);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   731
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   732
    ($s,$mn,$h,$d,$m,$y,$wday,$yday,$isdst)=localtime(time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   733
    $y+=1900;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   734
    $m++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   735
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   736
  &Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   737
  $Curr{"Y"}=$y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   738
  $Curr{"M"}=$m;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   739
  $Curr{"D"}=$d;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   740
  $Curr{"H"}=$h;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   741
  $Curr{"Mn"}=$mn;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   742
  $Curr{"S"}=$s;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   743
  $Curr{"AmPm"}=$ampm;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   744
  $Curr{"Now"}=&Date_Join($y,$m,$d,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   745
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   746
  $Curr{"Debug"}=$Curr{"DebugVal"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   747
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   748
  # If we're in array context, let's return a list of config variables
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   749
  # that could be passed to Date_Init to get the same state as we're
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   750
  # currently in.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   751
  if (wantarray) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   752
    # Some special variables that have to be in a specific order
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   753
    my(@special)=qw(IgnoreGlobalCnf GlobalCnf PersonalCnf PersonalCnfPath);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   754
    my(%tmp)=map { $_,1 } @special;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   755
    my(@tmp,$key,$val);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   756
    foreach $key (@special) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   757
      $val=$Cnf{$key};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   758
      push(@tmp,"$key=$val");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   759
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   760
    foreach $key (keys %Cnf) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   761
      next  if (exists $tmp{$key});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   762
      $val=$Cnf{$key};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   763
      push(@tmp,"$key=$val");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   764
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   765
    return @tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   766
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   767
  return ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   768
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   769
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   770
sub ParseDateString {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   771
  print "DEBUG: ParseDateString\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   772
  local($_)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   773
  return ""  if (! $_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   774
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   775
  my($y,$m,$d,$h,$mn,$s,$i,$wofm,$dofw,$wk,$tmp,$z,$num,$err,$iso,$ampm)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   776
  my($date,$z2,$delta,$from,$falsefrom,$to,$which,$midnight)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   777
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   778
  # We only need to reinitialize if we have to determine what NOW is.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   779
  &Date_Init()  if (! $Curr{"InitDone"}  or  $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   780
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   781
  my($L)=$Cnf{"Language"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   782
  my($type)=$Cnf{"DateFormat"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   783
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   784
  # Mode is set in DateCalc.  ParseDate only overrides it if the string
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   785
  # contains a mode.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   786
  if      ($Lang{$L}{"Exact"}  &&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   787
           s/$Lang{$L}{"Exact"}//) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   788
    $Curr{"Mode"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   789
  } elsif ($Lang{$L}{"Approx"}  &&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   790
           s/$Lang{$L}{"Approx"}//) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   791
    $Curr{"Mode"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   792
  } elsif ($Lang{$L}{"Business"}  &&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   793
           s/$Lang{$L}{"Business"}//) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   794
    $Curr{"Mode"}=2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   795
  } elsif (! exists $Curr{"Mode"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   796
    $Curr{"Mode"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   797
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   798
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   799
  # Unfortunately, some deltas can be parsed as dates.  An example is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   800
  #    1 second  ==  1 2nd  ==  1 2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   801
  # But, some dates can be parsed as deltas.  The most important being:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   802
  #    1998010101:00:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   803
  # We'll check to see if a "date" can be parsed as a delta.  If so, we'll
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   804
  # assume that it is a delta (since they are much simpler, it is much
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   805
  # less likely that we'll mistake a delta for a date than vice versa)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   806
  # unless it is an ISO-8601 date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   807
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   808
  # This is important because we are using DateCalc to test whether a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   809
  # string is a date or a delta.  Dates are tested first, so we need to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   810
  # be able to pass a delta into this routine and have it correctly NOT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   811
  # interpreted as a date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   812
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   813
  # We will insist that the string contain something other than digits and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   814
  # colons so that the following will get correctly interpreted as a date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   815
  # rather than a delta:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   816
  #     12:30
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   817
  #     19980101
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   818
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   819
  $delta="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   820
  $delta=&ParseDateDelta($_)  if (/[^:0-9]/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   821
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   822
  # Put parse in a simple loop for an easy exit.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   823
 PARSE: {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   824
    my(@tmp)=&Date_Split($_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   825
    if (@tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   826
      ($y,$m,$d,$h,$mn,$s)=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   827
      last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   828
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   829
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   830
    # Fundamental regular expressions
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   831
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   832
    my($month)=$Lang{$L}{"Month"};          # (jan|january|...)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   833
    my(%month)=%{ $Lang{$L}{"MonthH"} };    # { jan=>1, ... }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   834
    my($week)=$Lang{$L}{"Week"};            # (mon|monday|...)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   835
    my(%week)=%{ $Lang{$L}{"WeekH"} };      # { mon=>1, monday=>1, ... }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   836
    my($wom)=$Lang{$L}{"WoM"};              # (1st|...|fifth|last)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   837
    my(%wom)=%{ $Lang{$L}{"WoMH"} };        # { 1st=>1,... fifth=>5,last=>-1 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   838
    my($dom)=$Lang{$L}{"DoM"};              # (1st|first|...31st)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   839
    my(%dom)=%{ $Lang{$L}{"DoMH"} };        # { 1st=>1, first=>1, ... }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   840
    my($ampmexp)=$Lang{$L}{"AmPm"};         # (am|pm)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   841
    my($timeexp)=$Lang{$L}{"Times"};        # (noon|midnight)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   842
    my($now)=$Lang{$L}{"Now"};              # (now|today)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   843
    my($offset)=$Lang{$L}{"Offset"};        # (yesterday|tomorrow)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   844
    my($zone)=$Zone{"zones"} . '(?:\s+|$)'; # (edt|est|...)\s+
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   845
    my($day)='\s*'.$Lang{$L}{"Dabb"};       # \s*(?:d|day|days)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   846
    my($mabb)='\s*'.$Lang{$L}{"Mabb"};      # \s*(?:mon|month|months)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   847
    my($wkabb)='\s*'.$Lang{$L}{"Wabb"};     # \s*(?:w|wk|week|weeks)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   848
    my($next)='\s*'.$Lang{$L}{"Next"};      # \s*(?:next)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   849
    my($prev)='\s*'.$Lang{$L}{"Prev"};      # \s*(?:last|previous)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   850
    my($past)='\s*'.$Lang{$L}{"Past"};      # \s*(?:ago)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   851
    my($future)='\s*'.$Lang{$L}{"Future"};  # \s*(?:in)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   852
    my($later)='\s*'.$Lang{$L}{"Later"};    # \s*(?:later)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   853
    my($at)=$Lang{$L}{"At"};                # (?:at)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   854
    my($of)='\s*'.$Lang{$L}{"Of"};          # \s*(?:in|of)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   855
    my($on)='(?:\s*'.$Lang{$L}{"On"}.'\s*|\s+)';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   856
                                            # \s*(?:on)\s*    or  \s+
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   857
    my($last)='\s*'.$Lang{$L}{"Last"};      # \s*(?:last)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   858
    my($hm)=$Lang{$L}{"SepHM"};             # :
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   859
    my($ms)=$Lang{$L}{"SepMS"};             # :
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   860
    my($ss)=$Lang{$L}{"SepSS"};             # .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   861
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   862
    # Other regular expressions
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   863
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   864
    my($D4)='(\d{4})';            # 4 digits      (yr)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   865
    my($YY)='(\d{4}|\d{2})';      # 2 or 4 digits (yr)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   866
    my($DD)='(\d{2})';            # 2 digits      (mon/day/hr/min/sec)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   867
    my($D) ='(\d{1,2})';          # 1 or 2 digit  (mon/day/hr)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   868
    my($FS)="(?:$ss\\d+)?";       # fractional secs
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   869
    my($sep)='[\/.-]';            # non-ISO8601 m/d/yy separators
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   870
    # absolute time zone     +0700 (GMT)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   871
    my($hzone)='(?:[0-1][0-9]|2[0-3])';                    # 00 - 23
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   872
    my($mzone)='(?:[0-5][0-9])';                           # 00 - 59
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   873
    my($zone2)='(?:\s*([+-](?:'."$hzone$mzone|$hzone:$mzone|$hzone))".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   874
                                                           # +0700 +07:00 -07
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   875
      '(?:\s*\([^)]+\))?)';                                # (GMT)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   876
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   877
    # A regular expression for the time EXCEPT for the hour part
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   878
    my($mnsec)="$hm$DD(?:$ms$DD$FS)?(?:\\s*$ampmexp)?";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   879
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   880
    # A special regular expression for /YYYY:HH:MN:SS used by Apache
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   881
    my($apachetime)='(/\d{4}):' . "$DD$hm$DD$ms$DD";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   882
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   883
    my($time)="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   884
    $ampm="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   885
    $date="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   886
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   887
    # Substitute all special time expressions.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   888
    if (/(^|[^a-z])$timeexp($|[^a-z])/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   889
      $tmp=$2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   890
      $tmp=$Lang{$L}{"TimesH"}{lc($tmp)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   891
      s/(^|[^a-z])$timeexp($|[^a-z])/$1 $tmp $3/i;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   892
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   893
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   894
    # Remove some punctuation
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   895
    s/[,]/ /g;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   896
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   897
    # Make sure that ...7EST works (i.e. a timezone immediately following
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   898
    # a digit.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   899
    s/(\d)$zone(\s+|$|[0-9])/$1 $2$3/i;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   900
    $zone = '\s+'.$zone;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   901
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   902
    # Remove the time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   903
    $iso=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   904
    $midnight=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   905
    $from="24${hm}00(?:${ms}00)?";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   906
    $falsefrom="${hm}24${ms}00";   # Don't trap XX:24:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   907
    $to="00${hm}00${ms}00";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   908
    $midnight=1  if (!/$falsefrom/  &&  s/$from/$to/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   909
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   910
    $h=$mn=$s=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   911
    if (/$D$mnsec/i || /$ampmexp/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   912
      $iso=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   913
      $tmp=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   914
      $tmp=1  if (/$mnsec$zone2?\s*$/i);  # or /$mnsec$zone/ ??
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   915
      $tmp=0  if (/$ampmexp/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   916
      if (s/$apachetime$zone()/$1 /i                            ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   917
          s/$apachetime$zone2?/$1 /i                            ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   918
          s/(^|[^a-z])$at\s*$D$mnsec$zone()/$1 /i               ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   919
          s/(^|[^a-z])$at\s*$D$mnsec$zone2?/$1 /i               ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   920
          s/(^|[^0-9])(\d)$mnsec$zone()/$1 /i                   ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   921
          s/(^|[^0-9])(\d)$mnsec$zone2?/$1 /i                   ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   922
          (s/(t)$D$mnsec$zone()/$1 /i and (($iso=-$tmp) || 1))  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   923
          (s/(t)$D$mnsec$zone2?/$1 /i and (($iso=-$tmp) || 1))  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   924
          (s/()$DD$mnsec$zone()/ /i and (($iso=$tmp) || 1))     ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   925
          (s/()$DD$mnsec$zone2?/ /i and (($iso=$tmp) || 1))     ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   926
          s/(^|$at\s*|\s+)$D()()\s*$ampmexp$zone()/ /i          ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   927
          s/(^|$at\s*|\s+)$D()()\s*$ampmexp$zone2?/ /i          ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   928
          0
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   929
         ) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   930
        ($h,$mn,$s,$ampm,$z,$z2)=($2,$3,$4,$5,$6,$7);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   931
        if (defined ($z)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   932
          if ($z =~ /^[+-]\d{2}:\d{2}$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   933
            $z=~ s/://;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   934
          } elsif ($z =~ /^[+-]\d{2}$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   935
            $z .= "00";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   936
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   937
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   938
        $time=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   939
        &Date_TimeCheck(\$h,\$mn,\$s,\$ampm);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   940
        $y=$m=$d="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   941
        # We're going to be calling TimeCheck again below (when we check the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   942
        # final date), so get rid of $ampm so that we don't have an error
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   943
        # due to "15:30:00 PM".  It'll get reset below.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   944
        $ampm="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   945
        if (/^\s*$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   946
          &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   947
          last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   948
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   949
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   950
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   951
    $time=0  if ($time ne "1");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   952
    s/\s+$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   953
    s/^\s+//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   954
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   955
    # dateTtime ISO 8601 formats
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   956
    my($orig)=$_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   957
    s/t$//i  if ($iso<0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   958
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   959
    # Parse ISO 8601 dates now (which may still have a zone stuck to it).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   960
    if ( ($iso && /^([0-9-]+(?:W[0-9-]+)?)$zone?$/i)   ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   961
         ($iso && /^([0-9-]+(?:W[0-9-]+)?)$zone2?$/i)  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   962
         ($iso && /^([0-9-]+(?:T[0-9-]+)?)$zone?$/i)   ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   963
         ($iso && /^([0-9-]+(?:T[0-9-]+)?)$zone2?$/i)  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   964
         0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   965
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   966
      # ISO 8601 dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   967
      ($_,$z,$z2) = ($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   968
      s,-, ,g;            # Change all ISO8601 seps to spaces
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   969
      s/^\s+//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   970
      s/\s+$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   971
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   972
      if (/^$D4\s*$DD\s*$DD\s*t?$DD(?:$DD(?:$DD(\d*))?)?$/i ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   973
          /^$DD\s+$DD\s*$DD\s*t?$DD(?:$DD(?:$DD(\d*))?)?$/i ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   974
          0
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   975
         ) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   976
        # ISO 8601 Dates with times
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   977
        #    YYYYMMDDHHMNSSFFFF...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   978
        #    YYYYMMDDHHMNSS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   979
        #    YYYYMMDDHHMN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   980
        #    YYYYMMDDHH
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   981
        #    YY MMDDHHMNSSFFFF...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   982
        #    YY MMDDHHMNSS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   983
        #    YY MMDDHHMN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   984
        #    YY MMDDHH
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   985
        ($y,$m,$d,$h,$mn,$s,$tmp)=($1,$2,$3,$4,$5,$6,$7);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   986
        if ($h==24 && (! defined $mn || $mn==0) && (! defined $s || $s==0)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   987
          $h=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   988
          $midnight=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   989
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   990
        $z = ""    if (! defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   991
        return ""  if ($time  &&  defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   992
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   993
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   994
      } elsif (/^$D4(?:\s*$DD(?:\s*$DD)?)?$/  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   995
               /^$DD(?:\s+$DD(?:\s*$DD)?)?$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   996
        # ISO 8601 Dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   997
        #    YYYYMMDD
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   998
        #    YYYYMM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
   999
        #    YYYY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1000
        #    YY MMDD
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1001
        #    YY MM
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1002
        #    YY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1003
        ($y,$m,$d)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1004
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1005
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1006
      } elsif (/^$YY\s+$D\s+$D/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1007
        # YY-M-D
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1008
        ($y,$m,$d)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1009
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1010
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1011
      } elsif (/^$YY\s*W$DD\s*(\d)?$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1012
        # YY-W##-D
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1013
        ($y,$wofm,$dofw)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1014
        ($y,$m,$d)=&Date_NthWeekOfYear($y,$wofm,$dofw);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1015
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1016
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1017
      } elsif (/^$D4\s*(\d{3})$/ ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1018
               /^$DD\s*(\d{3})$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1019
        # YYDOY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1020
        ($y,$which)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1021
        ($y,$m,$d)=&Date_NthDayOfYear($y,$which);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1022
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1023
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1024
      } elsif ($iso<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1025
        # We confused something like 1999/August12:00:00
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1026
        # with a dateTtime format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1027
        $_=$orig;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1028
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1029
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1030
        return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1031
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1032
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1033
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1034
    # All deltas that are not ISO-8601 dates are NOT dates.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1035
    return ""  if ($Curr{"InCalc"}  &&  $delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1036
    if ($delta) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1037
      &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1038
      return &DateCalc_DateDelta($Curr{"Now"},$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1039
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1040
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1041
    # Check for some special types of dates (next, prev)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1042
    foreach $from (keys %{ $Lang{$L}{"Repl"} }) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1043
      $to=$Lang{$L}{"Repl"}{$from};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1044
      s/(^|[^a-z])$from($|[^a-z])/$1$to$2/i;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1045
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1046
    if (/$wom/i  ||  /$future/i  ||  /$later/i  ||  /$past/i  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1047
        /$next/i  ||  /$prev/i  ||  /^$week$/i  ||  /$wkabb/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1048
      $tmp=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1049
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1050
      if (/^$wom\s*$week$of\s*$month\s*$YY?$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1051
        # last friday in October 95
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1052
        ($wofm,$dofw,$m,$y)=($1,$2,$3,$4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1053
        # fix $m, $y
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1054
        return ""  if (&Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1055
        $dofw=$week{lc($dofw)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1056
        $wofm=$wom{lc($wofm)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1057
        # Get the first day of the month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1058
        $date=&Date_Join($y,$m,1,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1059
        if ($wofm==-1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1060
          $date=&DateCalc_DateDelta($date,"+0:1:0:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1061
          $date=&Date_GetPrev($date,$dofw,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1062
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1063
          for ($i=0; $i<$wofm; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1064
            if ($i==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1065
              $date=&Date_GetNext($date,$dofw,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1066
            } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1067
              $date=&Date_GetNext($date,$dofw,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1068
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1069
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1070
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1071
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1072
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1073
      } elsif (/^$last$day$of\s*$month(?:$of?\s*$YY)?/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1074
        # last day in month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1075
        ($m,$y)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1076
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1077
        $y=&Date_FixYear($y)  if (! defined $y  or  length($y)<4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1078
        $m=$month{lc($m)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1079
        $d=&Date_DaysInMonth($m,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1080
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1081
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1082
      } elsif (/^$week$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1083
        # friday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1084
        ($dofw)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1085
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1086
        $date=&Date_GetPrev($Curr{"Now"},$Cnf{"FirstDay"},1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1087
        $date=&Date_GetNext($date,$dofw,1,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1088
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1089
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1090
      } elsif (/^$next\s*$week$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1091
        # next friday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1092
        ($dofw)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1093
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1094
        $date=&Date_GetNext($Curr{"Now"},$dofw,0,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1095
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1096
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1097
      } elsif (/^$prev\s*$week$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1098
        # last friday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1099
        ($dofw)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1100
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1101
        $date=&Date_GetPrev($Curr{"Now"},$dofw,0,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1102
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1103
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1104
      } elsif (/^$next$wkabb$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1105
        # next week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1106
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1107
        $date=&DateCalc_DateDelta($Curr{"Now"},"+0:0:1:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1108
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1109
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1110
      } elsif (/^$prev$wkabb$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1111
        # last week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1112
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1113
        $date=&DateCalc_DateDelta($Curr{"Now"},"-0:0:1:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1114
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1115
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1116
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1117
      } elsif (/^$next$mabb$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1118
        # next month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1119
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1120
        $date=&DateCalc_DateDelta($Curr{"Now"},"+0:1:0:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1121
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1122
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1123
      } elsif (/^$prev$mabb$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1124
        # last month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1125
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1126
        $date=&DateCalc_DateDelta($Curr{"Now"},"-0:1:0:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1127
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1128
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1129
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1130
      } elsif (/^$future\s*(\d+)$day$/i  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1131
               /^(\d+)$day$later$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1132
        # in 2 days
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1133
        # 2 days later
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1134
        ($num)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1135
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1136
        $date=&DateCalc_DateDelta($Curr{"Now"},"+0:0:0:$num:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1137
                                  \$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1138
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1139
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1140
      } elsif (/^(\d+)$day$past$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1141
        # 2 days ago
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1142
        ($num)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1143
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1144
        $date=&DateCalc_DateDelta($Curr{"Now"},"-0:0:0:$num:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1145
                                 \$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1146
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1147
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1148
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1149
      } elsif (/^$future\s*(\d+)$wkabb$/i  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1150
               /^(\d+)$wkabb$later$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1151
        # in 2 weeks
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1152
        # 2 weeks later
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1153
        ($num)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1154
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1155
        $date=&DateCalc_DateDelta($Curr{"Now"},"+0:0:$num:0:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1156
                                  \$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1157
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1158
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1159
      } elsif (/^(\d+)$wkabb$past$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1160
        # 2 weeks ago
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1161
        ($num)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1162
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1163
        $date=&DateCalc_DateDelta($Curr{"Now"},"-0:0:$num:0:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1164
                                 \$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1165
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1166
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1167
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1168
      } elsif (/^$future\s*(\d+)$mabb$/i  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1169
               /^(\d+)$mabb$later$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1170
        # in 2 months
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1171
        # 2 months later
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1172
        ($num)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1173
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1174
        $date=&DateCalc_DateDelta($Curr{"Now"},"+0:$num:0:0:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1175
                                  \$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1176
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1177
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1178
      } elsif (/^(\d+)$mabb$past$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1179
        # 2 months ago
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1180
        ($num)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1181
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1182
        $date=&DateCalc_DateDelta($Curr{"Now"},"-0:$num:0:0:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1183
                                  \$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1184
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1185
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1186
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1187
      } elsif (/^$week$future\s*(\d+)$wkabb$/i  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1188
               /^$week\s*(\d+)$wkabb$later$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1189
        # friday in 2 weeks
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1190
        # friday 2 weeks later
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1191
        ($dofw,$num)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1192
        $tmp="+";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1193
      } elsif (/^$week\s*(\d+)$wkabb$past$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1194
        # friday 2 weeks ago
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1195
        ($dofw,$num)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1196
        $tmp="-";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1197
      } elsif (/^$future\s*(\d+)$wkabb$on$week$/i  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1198
               /^(\d+)$wkabb$later$on$week$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1199
        # in 2 weeks on friday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1200
        # 2 weeks later on friday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1201
        ($num,$dofw)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1202
        $tmp="+"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1203
      } elsif (/^(\d+)$wkabb$past$on$week$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1204
        # 2 weeks ago on friday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1205
        ($num,$dofw)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1206
        $tmp="-";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1207
      } elsif (/^$week\s*$wkabb$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1208
        # monday week    (British date: in 1 week on monday)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1209
        $dofw=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1210
        $num=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1211
        $tmp="+";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1212
      } elsif (/^$now\s*$wkabb$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1213
        # today week     (British date: 1 week from today)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1214
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1215
        $date=&DateCalc_DateDelta($Curr{"Now"},"+0:0:1:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1216
        $date=&Date_SetTime($date,$h,$mn,$s)  if (defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1217
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1218
      } elsif (/^$offset\s*$wkabb$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1219
        # tomorrow week  (British date: 1 week from tomorrow)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1220
        ($offset)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1221
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1222
        $offset=$Lang{$L}{"OffsetH"}{lc($offset)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1223
        $date=&DateCalc_DateDelta($Curr{"Now"},$offset,\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1224
        $date=&DateCalc_DateDelta($date,"+0:0:1:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1225
        if ($time) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1226
          return ""
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1227
            if (&Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1228
          $date=&Date_SetTime($date,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1229
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1230
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1231
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1232
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1233
      if ($tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1234
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1235
        $date=&DateCalc_DateDelta($Curr{"Now"},
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1236
                                  $tmp . "0:0:$num:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1237
        $date=&Date_GetPrev($date,$Cnf{"FirstDay"},1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1238
        $date=&Date_GetNext($date,$dofw,1,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1239
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1240
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1241
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1242
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1243
    # Change (2nd, second) to 2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1244
    $tmp=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1245
    if (/(^|[^a-z0-9])$dom($|[^a-z0-9])/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1246
      if (/^\s*$dom\s*$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1247
        ($d)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1248
        $d=$dom{lc($d)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1249
        $m=$Curr{"M"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1250
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1251
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1252
      my $from = $2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1253
      my $to   = $dom{ lc($from) };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1254
      s/(^|[^a-z])$from($|[^a-z])/$1 $to $2/i;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1255
      s/^\s+//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1256
      s/\s+$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1257
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1258
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1259
    # Another set of special dates (Nth week)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1260
    if (/^$D\s*$week(?:$of?\s*$YY)?$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1261
      # 22nd sunday in 1996
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1262
      ($which,$dofw,$y)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1263
      $y=$Curr{"Y"}  if (! $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1264
      $y--; # previous year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1265
      $tmp=&Date_GetNext("$y-12-31",$dofw,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1266
      if ($which>1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1267
        $tmp=&DateCalc_DateDelta($tmp,"+0:0:".($which-1).":0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1268
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1269
      ($y,$m,$d)=(&Date_Split($tmp, 1))[0..2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1270
      last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1271
    } elsif (/^$week$wkabb\s*$D(?:$of?\s*$YY)?$/i  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1272
             /^$week\s*$D$wkabb(?:$of?\s*$YY)?$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1273
      # sunday week 22 in 1996
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1274
      # sunday 22nd week in 1996
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1275
      ($dofw,$which,$y)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1276
      ($y,$m,$d)=&Date_NthWeekOfYear($y,$which,$dofw);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1277
      last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1278
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1279
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1280
    # Get rid of day of week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1281
    if (/(^|[^a-z])$week($|[^a-z])/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1282
      $wk=$2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1283
      (s/(^|[^a-z])$week,/$1 /i) ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1284
        s/(^|[^a-z])$week($|[^a-z])/$1 $3/i;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1285
      s/^\s+//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1286
      s/\s+$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1287
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1288
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1289
    {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1290
      # So that we can handle negative epoch times, let's convert
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1291
      # things like "epoch -" to "epochNEGATIVE " before we strip out
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1292
      # the $sep chars, which include '-'.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1293
      s,epoch\s*-,epochNEGATIVE ,g;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1294
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1295
      # Non-ISO8601 dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1296
      s,\s*$sep\s*, ,g;     # change all non-ISO8601 seps to spaces
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1297
      s,^\s*,,;             # remove leading/trailing space
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1298
      s,\s*$,,;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1299
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1300
      if (/^$D\s+$D(?:\s+$YY)?$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1301
        # MM DD YY (DD MM YY non-US)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1302
        ($m,$d,$y)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1303
        ($m,$d)=($d,$m)  if ($type ne "US");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1304
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1305
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1306
      } elsif (/^$D4\s*$D\s*$D$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1307
        # YYYY MM DD
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1308
        ($y,$m,$d)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1309
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1310
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1311
      } elsif (s/(^|[^a-z])$month($|[^a-z])/$1 $3/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1312
        ($m)=($2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1313
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1314
        if (/^\s*$D(?:\s+$YY)?\s*$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1315
          # mmm DD YY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1316
          # DD mmm YY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1317
          # DD YY mmm
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1318
          ($d,$y)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1319
          last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1320
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1321
        } elsif (/^\s*$D$D4\s*$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1322
          # mmm DD YYYY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1323
          # DD mmm YYYY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1324
          # DD YYYY mmm
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1325
          ($d,$y)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1326
          last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1327
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1328
        } elsif (/^\s*$D4\s*$D\s*$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1329
          # mmm YYYY DD
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1330
          # YYYY mmm DD
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1331
          # YYYY DD mmm
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1332
          ($y,$d)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1333
          last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1334
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1335
        } elsif (/^\s*$D4\s*$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1336
          # mmm YYYY
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1337
          # YYYY mmm
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1338
          ($y,$d)=($1,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1339
          last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1340
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1341
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1342
          return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1343
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1344
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1345
      } elsif (/^epochNEGATIVE (\d+)$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1346
        $s=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1347
        $date=&DateCalc("1970-01-01 00:00 GMT","-0:0:$s");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1348
      } elsif (/^epoch\s*(\d+)$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1349
        $s=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1350
        $date=&DateCalc("1970-01-01 00:00 GMT","+0:0:$s");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1351
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1352
      } elsif (/^$now$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1353
        # now, today
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1354
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1355
        $date=$Curr{"Now"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1356
        if ($time) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1357
          return ""
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1358
            if (&Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1359
          $date=&Date_SetTime($date,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1360
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1361
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1362
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1363
      } elsif (/^$offset$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1364
        # yesterday, tomorrow
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1365
        ($offset)=($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1366
        &Date_Init()  if (! $Cnf{"UpdateCurrTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1367
        $offset=$Lang{$L}{"OffsetH"}{lc($offset)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1368
        $date=&DateCalc_DateDelta($Curr{"Now"},$offset,\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1369
        if ($time) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1370
          return ""
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1371
            if (&Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1372
          $date=&Date_SetTime($date,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1373
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1374
        last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1375
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1376
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1377
        return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1378
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1379
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1380
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1381
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1382
  if (! $date) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1383
    return ""  if (&Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1384
    $date=&Date_Join($y,$m,$d,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1385
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1386
  $date=&Date_ConvTZ($date,$z);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1387
  if ($midnight) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1388
    $date=&DateCalc_DateDelta($date,"+0:0:0:1:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1389
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1390
  return $date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1391
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1392
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1393
sub ParseDate {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1394
  print "DEBUG: ParseDate\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1395
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1396
  my($args,@args,@a,$ref,$date)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1397
  @a=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1398
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1399
  # @a : is the list of args to ParseDate.  Currently, only one argument
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1400
  #      is allowed and it must be a scalar (or a reference to a scalar)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1401
  #      or a reference to an array.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1402
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1403
  if ($#a!=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1404
    print "ERROR:  Invalid number of arguments to ParseDate.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1405
    return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1406
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1407
  $args=$a[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1408
  $ref=ref $args;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1409
  if (! $ref) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1410
    return $args  if (&Date_Split($args));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1411
    @args=($args);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1412
  } elsif ($ref eq "ARRAY") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1413
    @args=@$args;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1414
  } elsif ($ref eq "SCALAR") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1415
    return $$args  if (&Date_Split($$args));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1416
    @args=($$args);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1417
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1418
    print "ERROR:  Invalid arguments to ParseDate.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1419
    return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1420
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1421
  @a=@args;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1422
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1423
  # @args : a list containing all the arguments (dereferenced if appropriate)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1424
  # @a    : a list containing all the arguments currently being examined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1425
  # $ref  : nil, "SCALAR", or "ARRAY" depending on whether a scalar, a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1426
  #         reference to a scalar, or a reference to an array was passed in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1427
  # $args : the scalar or refererence passed in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1428
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1429
 PARSE: while($#a>=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1430
    $date=join(" ",@a);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1431
    $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1432
    last  if ($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1433
    pop(@a);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1434
  } # PARSE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1435
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1436
  splice(@args,0,$#a + 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1437
  @$args= @args  if (defined $ref  and  $ref eq "ARRAY");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1438
  $date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1439
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1440
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1441
sub Date_Cmp {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1442
  my($D1,$D2)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1443
  my($date1)=&ParseDateString($D1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1444
  my($date2)=&ParseDateString($D2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1445
  return $date1 cmp $date2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1446
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1447
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1448
# **NOTE**
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1449
# The calc routines all call parse routines, so it is never necessary to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1450
# call Date_Init in the calc routines.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1451
sub DateCalc {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1452
  print "DEBUG: DateCalc\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1453
  my($D1,$D2,@arg)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1454
  my($ref,$err,$errref,$mode)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1455
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1456
  $errref=shift(@arg);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1457
  $ref=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1458
  if (defined $errref) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1459
    if (ref $errref) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1460
      $mode=shift(@arg);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1461
      $ref=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1462
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1463
      $mode=$errref;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1464
      $errref="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1465
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1466
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1467
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1468
  my(@date,@delta,$ret,$tmp,$old)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1469
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1470
  if (defined $mode  and  $mode>=0  and  $mode<=3) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1471
    $Curr{"Mode"}=$mode;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1472
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1473
    $Curr{"Mode"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1474
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1475
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1476
  $old=$Curr{"InCalc"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1477
  $Curr{"InCalc"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1478
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1479
  if ($tmp=&ParseDateString($D1)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1480
    # If we've already parsed the date, we don't want to do it a second
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1481
    # time (so we don't convert timezones twice).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1482
    if (&Date_Split($D1)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1483
      push(@date,$D1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1484
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1485
      push(@date,$tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1486
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1487
  } elsif ($tmp=&ParseDateDelta($D1)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1488
    push(@delta,$tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1489
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1490
    $$errref=1  if ($ref);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1491
    return;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1492
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1493
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1494
  if ($tmp=&ParseDateString($D2)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1495
    if (&Date_Split($D2)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1496
      push(@date,$D2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1497
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1498
      push(@date,$tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1499
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1500
  } elsif ($tmp=&ParseDateDelta($D2)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1501
    push(@delta,$tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1502
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1503
    $$errref=2  if ($ref);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1504
    return;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1505
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1506
  $mode=$Curr{"Mode"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1507
  $Curr{"InCalc"}=$old;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1508
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1509
  if ($#date==1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1510
    $ret=&DateCalc_DateDate(@date,$mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1511
  } elsif ($#date==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1512
    $ret=&DateCalc_DateDelta(@date,@delta,\$err,$mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1513
    $$errref=$err  if ($ref);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1514
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1515
    $ret=&DateCalc_DeltaDelta(@delta,$mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1516
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1517
  $ret;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1518
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1519
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1520
sub ParseDateDelta {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1521
  print "DEBUG: ParseDateDelta\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1522
  my($args,@args,@a,$ref)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1523
  local($_)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1524
  @a=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1525
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1526
  # @a : is the list of args to ParseDateDelta.  Currently, only one argument
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1527
  #      is allowed and it must be a scalar (or a reference to a scalar)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1528
  #      or a reference to an array.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1529
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1530
  if ($#a!=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1531
    print "ERROR:  Invalid number of arguments to ParseDateDelta.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1532
    return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1533
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1534
  $args=$a[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1535
  $ref=ref $args;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1536
  if (! $ref) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1537
    @args=($args);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1538
  } elsif ($ref eq "ARRAY") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1539
    @args=@$args;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1540
  } elsif ($ref eq "SCALAR") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1541
    @args=($$args);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1542
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1543
    print "ERROR:  Invalid arguments to ParseDateDelta.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1544
    return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1545
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1546
  @a=@args;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1547
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1548
  # @args : a list containing all the arguments (dereferenced if appropriate)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1549
  # @a    : a list containing all the arguments currently being examined
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1550
  # $ref  : nil, "SCALAR", or "ARRAY" depending on whether a scalar, a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1551
  #         reference to a scalar, or a reference to an array was passed in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1552
  # $args : the scalar or refererence passed in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1553
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1554
  my(@colon,@delta,$delta,$dir,$colon,$sign,$val)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1555
  my($len,$tmp,$tmp2,$tmpl)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1556
  my($from,$to)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1557
  my($workweek)=$Cnf{"WorkWeekEnd"}-$Cnf{"WorkWeekBeg"}+1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1558
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1559
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1560
  # A sign can be a sequence of zero or more + and - signs, this
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1561
  # allows for deltas like '+ -2 days'.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1562
  my($signexp)='((?:[+-]\s*)*)';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1563
  my($numexp)='(\d+)';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1564
  my($exp1)="(?: \\s* $signexp \\s* $numexp \\s*)";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1565
  my($yexp,$mexp,$wexp,$dexp,$hexp,$mnexp,$sexp,$i)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1566
  $yexp=$mexp=$wexp=$dexp=$hexp=$mnexp=$sexp="()()";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1567
  $yexp ="(?: $exp1 ". $Lang{$Cnf{"Language"}}{"Yabb"} .")?";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1568
  $mexp ="(?: $exp1 ". $Lang{$Cnf{"Language"}}{"Mabb"} .")?";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1569
  $wexp ="(?: $exp1 ". $Lang{$Cnf{"Language"}}{"Wabb"} .")?";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1570
  $dexp ="(?: $exp1 ". $Lang{$Cnf{"Language"}}{"Dabb"} .")?";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1571
  $hexp ="(?: $exp1 ". $Lang{$Cnf{"Language"}}{"Habb"} .")?";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1572
  $mnexp="(?: $exp1 ". $Lang{$Cnf{"Language"}}{"MNabb"}.")?";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1573
  $sexp ="(?: $exp1 ". $Lang{$Cnf{"Language"}}{"Sabb"} ."?)?";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1574
  my($future)=$Lang{$Cnf{"Language"}}{"Future"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1575
  my($later)=$Lang{$Cnf{"Language"}}{"Later"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1576
  my($past)=$Lang{$Cnf{"Language"}}{"Past"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1577
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1578
  $delta="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1579
 PARSE: while (@a) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1580
    $_ = join(" ", grep {defined;} @a);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1581
    s/\s+$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1582
    last  if ($_ eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1583
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1584
    # Mode is set in DateCalc.  ParseDateDelta only overrides it if the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1585
    # string contains a mode.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1586
    if      ($Lang{$Cnf{"Language"}}{"Exact"} &&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1587
             s/$Lang{$Cnf{"Language"}}{"Exact"}//) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1588
      $Curr{"Mode"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1589
    } elsif ($Lang{$Cnf{"Language"}}{"Approx"} &&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1590
             s/$Lang{$Cnf{"Language"}}{"Approx"}//) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1591
      $Curr{"Mode"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1592
    } elsif ($Lang{$Cnf{"Language"}}{"Business"} &&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1593
             s/$Lang{$Cnf{"Language"}}{"Business"}//) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1594
      $Curr{"Mode"}=2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1595
    } elsif (! exists $Curr{"Mode"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1596
      $Curr{"Mode"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1597
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1598
    $workweek=7  if ($Curr{"Mode"} != 2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1599
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1600
    foreach $from (keys %{ $Lang{$Cnf{"Language"}}{"Repl"} }) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1601
      $to=$Lang{$Cnf{"Language"}}{"Repl"}{$from};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1602
      s/(^|[^a-z])$from($|[^a-z])/$1$to$2/i;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1603
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1604
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1605
    # in or ago
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1606
    #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1607
    # We need to make sure that $later, $future, and $past don't contain each
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1608
    # other... Romanian pointed this out where $past is "in urma" and $future
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1609
    # is "in".  When they do, we have to take this into account.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1610
    #   $len  length of best match (greatest wins)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1611
    #   $tmp  string after best match
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1612
    #   $dir  direction (prior, after) of best match
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1613
    #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1614
    #   $tmp2 string before/after current match
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1615
    #   $tmpl length of current match
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1616
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1617
    $len=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1618
    $tmp=$_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1619
    $dir=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1620
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1621
    $tmp2=$_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1622
    if ($tmp2 =~ s/(^|[^a-z])($future)($|[^a-z])/$1 $3/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1623
      $tmpl=length($2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1624
      if ($tmpl>$len) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1625
        $tmp=$tmp2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1626
        $dir=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1627
        $len=$tmpl;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1628
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1629
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1630
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1631
    $tmp2=$_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1632
    if ($tmp2 =~ s/(^|[^a-z])($later)($|[^a-z])/$1 $3/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1633
      $tmpl=length($2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1634
      if ($tmpl>$len) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1635
        $tmp=$tmp2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1636
        $dir=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1637
        $len=$tmpl;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1638
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1639
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1640
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1641
    $tmp2=$_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1642
    if ($tmp2 =~ s/(^|[^a-z])($past)($|[^a-z])/$1 $3/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1643
      $tmpl=length($2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1644
      if ($tmpl>$len) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1645
        $tmp=$tmp2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1646
        $dir=-1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1647
        $len=$tmpl;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1648
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1649
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1650
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1651
    $_ = $tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1652
    s/\s*$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1653
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1654
    # the colon part of the delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1655
    $colon="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1656
    if (s/($signexp?$numexp?(:($signexp?$numexp)?){1,6})$//) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1657
      $colon=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1658
      s/\s+$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1659
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1660
    @colon=split(/:/,$colon);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1661
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1662
    # the non-colon part of the delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1663
    $sign="+";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1664
    @delta=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1665
    $i=6;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1666
    foreach $exp1 ($yexp,$mexp,$wexp,$dexp,$hexp,$mnexp,$sexp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1667
      last  if ($#colon>=$i--);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1668
      $val=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1669
      if (s/^$exp1//ix) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1670
        $val=$2   if ($2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1671
        $sign=$1  if ($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1672
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1673
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1674
      # Collapse a sign like '+ -' into a single character like '-',
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1675
      # by counting the occurrences of '-'.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1676
      #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1677
      $sign =~ s/\s+//g;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1678
      $sign =~ tr/+//d;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1679
      my $count = ($sign =~ tr/-//d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1680
      die "bad characters in sign: $sign" if length $sign;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1681
      $sign = $count % 2 ? '-' : '+';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1682
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1683
      push(@delta,"$sign$val");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1684
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1685
    if (! /^\s*$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1686
      pop(@a);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1687
      next PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1688
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1689
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1690
    # make sure that the colon part has a sign
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1691
    for ($i=0; $i<=$#colon; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1692
      $val=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1693
      if ($colon[$i] =~ /^$signexp$numexp?/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1694
        $val=$2   if ($2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1695
        $sign=$1  if ($1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1696
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1697
      $colon[$i] = "$sign$val";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1698
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1699
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1700
    # combine the two
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1701
    push(@delta,@colon);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1702
    if ($dir<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1703
      for ($i=0; $i<=$#delta; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1704
        $delta[$i] =~ tr/-+/+-/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1705
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1706
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1707
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1708
    # form the delta and shift off the valid part
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1709
    $delta=join(":",@delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1710
    splice(@args,0,$#a+1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1711
    @$args=@args  if (defined $ref  and  $ref eq "ARRAY");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1712
    last PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1713
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1714
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1715
  $delta=&Delta_Normalize($delta,$Curr{"Mode"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1716
  return $delta;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1717
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1718
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1719
sub UnixDate {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1720
  print "DEBUG: UnixDate\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1721
  my($date,@format)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1722
  local($_)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1723
  my($format,%f,$out,@out,$c,$date1,$date2,$tmp)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1724
  my($scalar)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1725
  $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1726
  return  if (! $date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1727
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1728
  my($y,$m,$d,$h,$mn,$s)=($f{"Y"},$f{"m"},$f{"d"},$f{"H"},$f{"M"},$f{"S"})=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1729
    &Date_Split($date, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1730
  $f{"y"}=substr $f{"Y"},2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1731
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1732
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1733
  if (! wantarray) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1734
    $format=join(" ",@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1735
    @format=($format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1736
    $scalar=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1737
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1738
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1739
  # month, week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1740
  $_=$m;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1741
  s/^0//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1742
  $f{"b"}=$f{"h"}=$Lang{$Cnf{"Language"}}{"MonL"}[$_-1];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1743
  $f{"B"}=$Lang{$Cnf{"Language"}}{"MonthL"}[$_-1];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1744
  $_=$m;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1745
  s/^0/ /;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1746
  $f{"f"}=$_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1747
  $f{"U"}=&Date_WeekOfYear($m,$d,$y,7);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1748
  $f{"W"}=&Date_WeekOfYear($m,$d,$y,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1749
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1750
  # check week 52,53 and 0
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1751
  $f{"G"}=$f{"L"}=$y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1752
  if ($f{"W"}>=52 || $f{"U"}>=52) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1753
    my($dd,$mm,$yy)=($d,$m,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1754
    $dd+=7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1755
    if ($dd>31) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1756
      $dd-=31;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1757
      $mm=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1758
      $yy++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1759
      if (&Date_WeekOfYear($mm,$dd,$yy,1)==2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1760
        $f{"G"}=$yy;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1761
        $f{"W"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1762
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1763
      if (&Date_WeekOfYear($mm,$dd,$yy,7)==2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1764
        $f{"L"}=$yy;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1765
        $f{"U"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1766
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1767
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1768
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1769
  if ($f{"W"}==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1770
    my($dd,$mm,$yy)=($d,$m,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1771
    $dd-=7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1772
    $dd+=31  if ($dd<1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1773
    $yy--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1774
    $mm=12;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1775
    $f{"G"}=$yy;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1776
    $f{"W"}=&Date_WeekOfYear($mm,$dd,$yy,1)+1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1777
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1778
  if ($f{"U"}==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1779
    my($dd,$mm,$yy)=($d,$m,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1780
    $dd-=7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1781
    $dd+=31  if ($dd<1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1782
    $yy--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1783
    $mm=12;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1784
    $f{"L"}=$yy;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1785
    $f{"U"}=&Date_WeekOfYear($mm,$dd,$yy,7)+1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1786
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1787
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1788
  $f{"U"}="0".$f{"U"}  if (length $f{"U"} < 2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1789
  $f{"W"}="0".$f{"W"}  if (length $f{"W"} < 2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1790
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1791
  # day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1792
  $f{"j"}=&Date_DayOfYear($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1793
  $f{"j"} = "0" . $f{"j"}   while (length($f{"j"})<3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1794
  $_=$d;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1795
  s/^0/ /;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1796
  $f{"e"}=$_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1797
  $f{"w"}=&Date_DayOfWeek($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1798
  $f{"v"}=$Lang{$Cnf{"Language"}}{"WL"}[$f{"w"}-1];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1799
  $f{"v"}=" ".$f{"v"}  if (length $f{"v"} < 2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1800
  $f{"a"}=$Lang{$Cnf{"Language"}}{"WkL"}[$f{"w"}-1];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1801
  $f{"A"}=$Lang{$Cnf{"Language"}}{"WeekL"}[$f{"w"}-1];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1802
  $f{"E"}=&Date_DaySuffix($f{"e"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1803
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1804
  # hour
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1805
  $_=$h;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1806
  s/^0/ /;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1807
  $f{"k"}=$_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1808
  $f{"i"}=$f{"k"}+1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1809
  $f{"i"}=$f{"k"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1810
  $f{"i"}=12          if ($f{"k"}==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1811
  $f{"i"}=$f{"k"}-12  if ($f{"k"}>12);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1812
  $f{"i"}=$f{"i"}-12  if ($f{"i"}>12);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1813
  $f{"i"}=" ".$f{"i"} if (length($f{"i"})<2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1814
  $f{"I"}=$f{"i"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1815
  $f{"I"}=~ s/^ /0/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1816
  $f{"p"}=$Lang{$Cnf{"Language"}}{"AMstr"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1817
  $f{"p"}=$Lang{$Cnf{"Language"}}{"PMstr"}  if ($f{"k"}>11);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1818
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1819
  # minute, second, timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1820
  $f{"o"}=&Date_SecsSince1970($m,$d,$y,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1821
  $f{"s"}=&Date_SecsSince1970GMT($m,$d,$y,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1822
  $f{"Z"}=($Cnf{"ConvTZ"} eq "IGNORE" or $Cnf{"ConvTZ"} eq "") ?
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1823
           $Cnf{"TZ"} : $Cnf{"ConvTZ"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1824
  $f{"z"}=($f{"Z"}=~/^[+-]\d{4}/) ? $f{"Z"} : ($Zone{"n2o"}{lc $f{"Z"}} || "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1825
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1826
  # date, time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1827
  $f{"c"}=qq|$f{"a"} $f{"b"} $f{"e"} $h:$mn:$s $y|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1828
  $f{"C"}=$f{"u"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1829
    qq|$f{"a"} $f{"b"} $f{"e"} $h:$mn:$s $f{"z"} $y|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1830
  $f{"g"}=qq|$f{"a"}, $d $f{"b"} $y $h:$mn:$s $f{"z"}|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1831
  $f{"D"}=$f{"x"}=qq|$m/$d/$f{"y"}|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1832
  $f{"r"}=qq|$f{"I"}:$mn:$s $f{"p"}|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1833
  $f{"R"}=qq|$h:$mn|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1834
  $f{"T"}=$f{"X"}=qq|$h:$mn:$s|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1835
  $f{"V"}=qq|$m$d$h$mn$f{"y"}|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1836
  $f{"Q"}="$y$m$d";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1837
  $f{"q"}=qq|$y$m$d$h$mn$s|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1838
  $f{"P"}=qq|$y$m$d$h:$mn:$s|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1839
  $f{"F"}=qq|$f{"A"}, $f{"B"} $f{"e"}, $f{"Y"}|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1840
  if ($f{"W"}==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1841
    $y--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1842
    $tmp=&Date_WeekOfYear(12,31,$y,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1843
    $tmp="0$tmp"  if (length($tmp) < 2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1844
    $f{"J"}=qq|$y-W$tmp-$f{"w"}|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1845
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1846
    $f{"J"}=qq|$f{"G"}-W$f{"W"}-$f{"w"}|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1847
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1848
  $f{"K"}=qq|$y-$f{"j"}|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1849
  # %l is a special case.  Since it requires the use of the calculator
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1850
  # which requires this routine, an infinite recursion results.  To get
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1851
  # around this, %l is NOT determined every time this is called so the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1852
  # recursion breaks.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1853
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1854
  # other formats
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1855
  $f{"n"}="\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1856
  $f{"t"}="\t";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1857
  $f{"%"}="%";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1858
  $f{"+"}="+";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1859
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1860
  foreach $format (@format) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1861
    $format=reverse($format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1862
    $out="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1863
    while ($format ne "") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1864
      $c=chop($format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1865
      if ($c eq "%") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1866
        $c=chop($format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1867
        if ($c eq "l") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1868
          &Date_Init();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1869
          $date1=&DateCalc_DateDelta($Curr{"Now"},"-0:6:0:0:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1870
          $date2=&DateCalc_DateDelta($Curr{"Now"},"+0:6:0:0:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1871
          if (&Date_Cmp($date,$date1)>=0  &&  &Date_Cmp($date,$date2)<=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1872
            $f{"l"}=qq|$f{"b"} $f{"e"} $h:$mn|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1873
          } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1874
            $f{"l"}=qq|$f{"b"} $f{"e"}  $f{"Y"}|;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1875
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1876
          $out .= $f{"$c"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1877
        } elsif (exists $f{"$c"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1878
          $out .= $f{"$c"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1879
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1880
          $out .= $c;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1881
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1882
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1883
        $out .= $c;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1884
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1885
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1886
    push(@out,$out);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1887
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1888
  if ($scalar) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1889
    return $out[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1890
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1891
    return (@out);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1892
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1893
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1894
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1895
# Can't be in "use integer" because we're doing decimal arithmatic
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1896
no integer;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1897
sub Delta_Format {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1898
  print "DEBUG: Delta_Format\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1899
  my($delta,$dec,@format)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1900
  $delta=&ParseDateDelta($delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1901
  return ""  if (! $delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1902
  my(@out,%f,$out,$c1,$c2,$scalar,$format)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1903
  local($_)=$delta;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1904
  my($y,$M,$w,$d,$h,$m,$s)=&Delta_Split($delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1905
  # Get rid of positive signs.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1906
  ($y,$M,$w,$d,$h,$m,$s)=map { 1*$_; }($y,$M,$w,$d,$h,$m,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1907
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1908
  if (defined $dec  &&  $dec>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1909
    $dec="%." . ($dec*1) . "f";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1910
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1911
    $dec="%f";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1912
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1913
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1914
  if (! wantarray) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1915
    $format=join(" ",@format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1916
    @format=($format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1917
    $scalar=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1918
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1919
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1920
  # Length of each unit in seconds
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1921
  my($sl,$ml,$hl,$dl,$wl,$yl)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1922
  $sl = 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1923
  $ml = $sl*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1924
  $hl = $ml*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1925
  $dl = $hl*24;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1926
  $wl = $dl*7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1927
  $yl = $dl*365.25;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1928
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1929
  # The decimal amount of each unit contained in all smaller units
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1930
  my($yd,$Md,$sd,$md,$hd,$dd,$wd)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1931
  if ($M) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1932
    $yd = $M/12;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1933
    $Md = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1934
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1935
    $yd = ($w*$wl + $d*$dl + $h*$hl + $m*$ml + $s*$sl)/$yl;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1936
    $Md = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1937
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1938
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1939
  $wd = ($d*$dl + $h*$hl + $m*$ml + $s*$sl)/$wl;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1940
  $dd =          ($h*$hl + $m*$ml + $s*$sl)/$dl;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1941
  $hd =                   ($m*$ml + $s*$sl)/$hl;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1942
  $md =                            ($s*$sl)/$ml;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1943
  $sd = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1944
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1945
  # The amount of each unit contained in higher units.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1946
  my($yh,$Mh,$sh,$mh,$hh,$dh,$wh)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1947
  $yh = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1948
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1949
  if ($M) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1950
    $Mh = ($yh+$y)*12;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1951
    $wh = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1952
    $dh = ($wh+$w)*7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1953
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1954
    $Mh = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1955
    $wh = ($yh+$y)*365.25/7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1956
    $dh = ($yh+$y)*365.25 + $w*7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1957
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1958
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1959
  $hh = ($dh+$d)*24;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1960
  $mh = ($hh+$h)*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1961
  $sh = ($mh+$m)*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1962
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1963
  # Set up the formats
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1964
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1965
  $f{"yv"} = $y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1966
  $f{"Mv"} = $M;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1967
  $f{"wv"} = $w;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1968
  $f{"dv"} = $d;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1969
  $f{"hv"} = $h;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1970
  $f{"mv"} = $m;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1971
  $f{"sv"} = $s;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1972
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1973
  $f{"yh"} = $y+$yh;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1974
  $f{"Mh"} = $M+$Mh;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1975
  $f{"wh"} = $w+$wh;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1976
  $f{"dh"} = $d+$dh;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1977
  $f{"hh"} = $h+$hh;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1978
  $f{"mh"} = $m+$mh;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1979
  $f{"sh"} = $s+$sh;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1980
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1981
  $f{"yd"} = sprintf($dec,$y+$yd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1982
  $f{"Md"} = sprintf($dec,$M+$Md);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1983
  $f{"wd"} = sprintf($dec,$w+$wd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1984
  $f{"dd"} = sprintf($dec,$d+$dd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1985
  $f{"hd"} = sprintf($dec,$h+$hd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1986
  $f{"md"} = sprintf($dec,$m+$md);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1987
  $f{"sd"} = sprintf($dec,$s+$sd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1988
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1989
  $f{"yt"} = sprintf($dec,$yh+$y+$yd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1990
  $f{"Mt"} = sprintf($dec,$Mh+$M+$Md);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1991
  $f{"wt"} = sprintf($dec,$wh+$w+$wd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1992
  $f{"dt"} = sprintf($dec,$dh+$d+$dd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1993
  $f{"ht"} = sprintf($dec,$hh+$h+$hd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1994
  $f{"mt"} = sprintf($dec,$mh+$m+$md);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1995
  $f{"st"} = sprintf($dec,$sh+$s+$sd);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1996
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1997
  $f{"%"}  = "%";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1998
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  1999
  foreach $format (@format) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2000
    $format=reverse($format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2001
    $out="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2002
  PARSE: while ($format) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2003
      $c1=chop($format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2004
      if ($c1 eq "%") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2005
        $c1=chop($format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2006
        if (exists($f{$c1})) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2007
          $out .= $f{$c1};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2008
          next PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2009
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2010
        $c2=chop($format);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2011
        if (exists($f{"$c1$c2"})) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2012
          $out .= $f{"$c1$c2"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2013
          next PARSE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2014
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2015
        $out .= $c1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2016
        $format .= $c2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2017
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2018
        $out .= $c1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2019
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2020
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2021
    push(@out,$out);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2022
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2023
  if ($scalar) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2024
    return $out[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2025
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2026
    return (@out);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2027
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2028
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2029
use integer;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2030
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2031
sub ParseRecur {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2032
  print "DEBUG: ParseRecur\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2033
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2034
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2035
  my($recur,$dateb,$date0,$date1,$flag)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2036
  local($_)=$recur;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2037
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2038
  my($recur_0,$recur_1,@recur0,@recur1)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2039
  my(@tmp,$tmp,$each,$num,$y,$m,$d,$w,$h,$mn,$s,$delta,$y0,$y1,$yb)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2040
  my($yy,$n,$dd,@d,@tmp2,$date,@date,@w,@tmp3,@m,@y,$tmp2,$d2,@flags)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2041
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2042
  # $date0, $date1, $dateb, $flag : passed in (these are always the final say
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2043
  #                                 in determining whether a date matches a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2044
  #                                 recurrence IF they are present.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2045
  # $date_b, $date_0, $date_1     : if a value can be determined from the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2046
  # $flag_t                         recurrence, they are stored here.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2047
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2048
  # If values can be determined from the recurrence AND are passed in, the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2049
  # following are used:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2050
  #    max($date0,$date_0)    i.e. the later of the two dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2051
  #    min($date1,$date_1)    i.e. the earlier of the two dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2052
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2053
  # The base date that is used is the first one defined from
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2054
  #    $dateb $date_b
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2055
  # The base date is only used if necessary (as determined by the recur).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2056
  # For example, "every other friday" requires a base date, but "2nd
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2057
  # friday of every month" doesn't.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2058
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2059
  my($date_b,$date_0,$date_1,$flag_t);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2060
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2061
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2062
  # Check the arguments passed in.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2063
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2064
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2065
  $date0=""  if (! defined $date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2066
  $date1=""  if (! defined $date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2067
  $dateb=""  if (! defined $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2068
  $flag =""  if (! defined $flag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2069
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2070
  if ($dateb) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2071
    $dateb=&ParseDateString($dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2072
    return ""  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2073
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2074
  if ($date0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2075
    $date0=&ParseDateString($date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2076
    return ""  if (! $date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2077
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2078
  if ($date1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2079
    $date1=&ParseDateString($date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2080
    return ""  if (! $date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2081
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2082
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2083
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2084
  # Parse the recur.  $date_b, $date_0, and $date_e are values obtained
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2085
  # from the recur.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2086
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2087
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2088
  @tmp=&Recur_Split($_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2089
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2090
  if (@tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2091
    ($recur_0,$recur_1,$flag_t,$date_b,$date_0,$date_1)=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2092
    $recur_0 = ""  if (! defined $recur_0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2093
    $recur_1 = ""  if (! defined $recur_1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2094
    $flag_t  = ""  if (! defined $flag_t);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2095
    $date_b  = ""  if (! defined $date_b);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2096
    $date_0  = ""  if (! defined $date_0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2097
    $date_1  = ""  if (! defined $date_1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2098
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2099
    @recur0 = split(/:/,$recur_0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2100
    @recur1 = split(/:/,$recur_1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2101
    return ""  if ($#recur0 + $#recur1 + 2 != 7);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2102
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2103
    if ($date_b) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2104
      $date_b=&ParseDateString($date_b);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2105
      return ""  if (! $date_b);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2106
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2107
    if ($date_0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2108
      $date_0=&ParseDateString($date_0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2109
      return ""  if (! $date_0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2110
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2111
    if ($date_1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2112
      $date_1=&ParseDateString($date_1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2113
      return ""  if (! $date_1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2114
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2115
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2116
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2117
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2118
    my($mmm)='\s*'.$Lang{$Cnf{"Language"}}{"Month"};  # \s*(jan|january|...)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2119
    my(%mmm)=%{ $Lang{$Cnf{"Language"}}{"MonthH"} };  # { jan=>1, ... }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2120
    my($wkexp)='\s*'.$Lang{$Cnf{"Language"}}{"Week"}; # \s*(mon|monday|...)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2121
    my(%week)=%{ $Lang{$Cnf{"Language"}}{"WeekH"} };  # { monday=>1, ... }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2122
    my($day)='\s*'.$Lang{$Cnf{"Language"}}{"Dabb"};   # \s*(?:d|day|days)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2123
    my($month)='\s*'.$Lang{$Cnf{"Language"}}{"Mabb"}; # \s*(?:mon|month|months)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2124
    my($week)='\s*'.$Lang{$Cnf{"Language"}}{"Wabb"};  # \s*(?:w|wk|week|weeks)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2125
    my($daysexp)=$Lang{$Cnf{"Language"}}{"DoM"};      # (1st|first|...31st)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2126
    my(%dayshash)=%{ $Lang{$Cnf{"Language"}}{"DoMH"} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2127
                                                      # { 1st=>1,first=>1,...}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2128
    my($of)='\s*'.$Lang{$Cnf{"Language"}}{"Of"};      # \s*(?:in|of)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2129
    my($lastexp)=$Lang{$Cnf{"Language"}}{"Last"};     # (?:last)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2130
    my($each)=$Lang{$Cnf{"Language"}}{"Each"};        # (?:each|every)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2131
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2132
    my($D)='\s*(\d+)';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2133
    my($Y)='\s*(\d{4}|\d{2})';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2134
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2135
    # Change 1st to 1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2136
    if (/(^|[^a-z])$daysexp($|[^a-z])/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2137
      $tmp=lc($2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2138
      $tmp=$dayshash{"$tmp"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2139
      s/(^|[^a-z])$daysexp($|[^a-z])/$1 $tmp $3/i;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2140
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2141
    s/\s*$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2142
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2143
    # Get rid of "each"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2144
    if (/(^|[^a-z])$each($|[^a-z])/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2145
      s/(^|[^a-z])$each($|[^a-z])/$1 $2/i;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2146
      $each=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2147
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2148
      $each=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2149
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2150
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2151
    if ($each) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2152
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2153
      if (/^$D?$day(?:$of$mmm?$Y)?$/i ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2154
          /^$D?$day(?:$of$mmm())?$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2155
        # every [2nd] day in [june] 1997
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2156
        # every [2nd] day [in june]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2157
        ($num,$m,$y)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2158
        $num=1 if (! defined $num);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2159
        $m=""  if (! defined $m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2160
        $y=""  if (! defined $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2161
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2162
        $y=$Curr{"Y"}  if (! $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2163
        if ($m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2164
          $m=$mmm{lc($m)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2165
          $date_0=&Date_Join($y,$m,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2166
          $date_1=&DateCalc_DateDelta($date_0,"+0:1:0:0:0:0:0",0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2167
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2168
          $date_0=&Date_Join($y,  1,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2169
          $date_1=&Date_Join($y+1,1,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2170
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2171
        $date_b=&DateCalc($date_0,"-0:0:0:1:0:0:0",0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2172
        @recur0=(0,0,0,$num,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2173
        @recur1=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2174
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2175
      } elsif (/^$D$day?$of$month(?:$of?$Y)?$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2176
        # 2nd [day] of every month [in 1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2177
        ($num,$y)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2178
        $y=$Curr{"Y"}  if (! $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2179
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2180
        $date_0=&Date_Join($y,  1,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2181
        $date_1=&Date_Join($y+1,1,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2182
        $date_b=$date_0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2183
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2184
        @recur0=(0,1,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2185
        @recur1=($num,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2186
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2187
      } elsif (/^$D$wkexp$of$month(?:$of?$Y)?$/ ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2188
               /^($lastexp)$wkexp$of$month(?:$of?$Y)?$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2189
        # 2nd tuesday of every month [in 1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2190
        # last tuesday of every month [in 1997]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2191
        ($num,$d,$y)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2192
        $y=$Curr{"Y"}  if (! $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2193
        $d=$week{lc($d)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2194
        $num=-1  if ($num !~ /^$D$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2195
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2196
        $date_0=&Date_Join($y,1,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2197
        $date_1=&Date_Join($y+1,1,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2198
        $date_b=$date_0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2199
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2200
        @recur0=(0,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2201
        @recur1=($num,$d,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2202
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2203
      } elsif (/^$D?$wkexp(?:$of$mmm?$Y)?$/i ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2204
               /^$D?$wkexp(?:$of$mmm())?$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2205
        # every tuesday in june 1997
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2206
        # every 2nd tuesday in june 1997
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2207
        ($num,$d,$m,$y)=($1,$2,$3,$4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2208
        $y=$Curr{"Y"}  if (! $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2209
        $num=1 if (! defined $num);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2210
        $m=""  if (! defined $m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2211
        $d=$week{lc($d)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2212
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2213
        if ($m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2214
          $m=$mmm{lc($m)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2215
          $date_0=&Date_Join($y,$m,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2216
          $date_1=&DateCalc_DateDelta($date_0,"+0:1:0:0:0:0:0",0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2217
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2218
          $date_0=&Date_Join($y,1,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2219
          $date_1=&Date_Join($y+1,1,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2220
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2221
        $date_b=&DateCalc($date_0,"-0:0:0:1:0:0:0",0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2222
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2223
        @recur0=(0,0,$num);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2224
        @recur1=($d,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2225
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2226
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2227
        return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2228
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2229
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2230
      $date_0=""  if ($date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2231
      $date_1=""  if ($date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2232
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2233
      return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2234
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2235
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2236
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2237
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2238
  # Override with any values passed in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2239
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2240
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2241
  if ($date0 && $date_0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2242
    $date0=( &Date_Cmp($date0,$date_0) > 1  ? $date0 : $date_0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2243
  } elsif ($date_0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2244
    $date0 = $date_0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2245
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2246
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2247
  if ($date1 && $date_1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2248
    $date1=( &Date_Cmp($date1,$date_1) > 1  ? $date_1 : $date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2249
  } elsif ($date_1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2250
    $date1 = $date_1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2251
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2252
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2253
  $dateb=$date_b  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2254
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2255
  if ($flag =~ s/^\+//) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2256
    if ($flag_t) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2257
      $flag="$flag_t,$flag";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2258
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2259
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2260
  $flag =$flag_t  if (! $flag  &&  $flag_t);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2261
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2262
  if (! wantarray) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2263
    $tmp  = join(":",@recur0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2264
    $tmp .= "*" . join(":",@recur1)  if (@recur1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2265
    $tmp .= "*$flag*$dateb*$date0*$date1";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2266
    return $tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2267
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2268
  if (@recur0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2269
    return ()  if (! $date0  ||  ! $date1); # dateb is NOT required in all case
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2270
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2271
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2272
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2273
  # Some flags affect parsing.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2274
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2275
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2276
  @flags   = split(/,/,$flag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2277
  my($MDn) = 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2278
  my($MWn) = 7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2279
  my($f);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2280
  foreach $f (@flags) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2281
    if ($f =~ /^MW([1-7])$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2282
      $MWn=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2283
      $MDn=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2284
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2285
    } elsif ($f =~ /^MD([1-7])$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2286
      $MDn=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2287
      $MWn=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2288
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2289
    } elsif ($f =~ /^EASTER$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2290
      ($y,$m,$w,$d,$h,$mn,$s)=(@recur0,@recur1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2291
      # We want something that will return Jan 1 for the given years.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2292
      if ($#recur0==-1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2293
        @recur1=($y,1,0,1,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2294
      } elsif ($#recur0<=3) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2295
        @recur0=($y,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2296
        @recur1=($h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2297
      } elsif ($#recur0==4) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2298
        @recur0=($y,0,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2299
        @recur1=($mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2300
      } elsif ($#recur0==5) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2301
        @recur0=($y,0,0,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2302
        @recur1=($s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2303
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2304
        @recur0=($y,0,0,0,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2305
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2306
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2307
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2308
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2309
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2310
  # Determine the dates referenced by the recur.  Also, fix the base date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2311
  # as necessary for the recurrences which require it.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2312
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2313
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2314
  ($y,$m,$w,$d,$h,$mn,$s)=(@recur0,@recur1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2315
  @y=@m=@w=@d=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2316
  my(@time)=($h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2317
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2318
 RECUR: while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2319
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2320
    if ($#recur0==-1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2321
      # * Y-M-W-D-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2322
      if ($y eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2323
        push(@recur0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2324
        shift(@recur1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2325
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2326
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2327
        @y=&ReturnList($y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2328
        foreach $y (@y) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2329
          $y=&Date_FixYear($y)  if (length($y)==2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2330
          return ()  if (length($y)!=4  ||  ! &IsInt($y));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2331
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2332
        @y=sort { $a<=>$b } @y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2333
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2334
        $date0=&ParseDate("0000-01-01")          if (! $date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2335
        $date1=&ParseDate("9999-12-31 23:59:59") if (! $date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2336
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2337
        if ($m eq "0"  and  $w eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2338
          # * Y-0-0-0-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2339
          # * Y-0-0-DOY-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2340
          if ($d eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2341
            @d=(1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2342
          } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2343
            @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2344
            return ()  if (! @d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2345
            foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2346
              return ()  if (! &IsInt($d,1,366));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2347
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2348
            @d=sort { $a<=>$b } (@d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2349
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2350
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2351
          @date=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2352
          foreach $yy (@y) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2353
            foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2354
              ($y,$m,$dd)=&Date_NthDayOfYear($yy,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2355
              push(@date, &Date_Join($y,$m,$dd,0,0,0));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2356
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2357
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2358
          last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2359
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2360
        } elsif ($w eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2361
          # * Y-M-0-0-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2362
          # * Y-M-0-DOM-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2363
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2364
          @m=&ReturnList($m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2365
          return ()  if (! @m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2366
          foreach $m (@m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2367
            return ()  if (! &IsInt($m,1,12));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2368
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2369
          @m=sort { $a<=>$b } (@m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2370
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2371
          if ($d eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2372
            @d=(1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2373
          } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2374
            @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2375
            return ()  if (! @d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2376
            foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2377
              return ()  if (! &IsInt($d,1,31));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2378
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2379
            @d=sort { $a<=>$b } (@d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2380
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2381
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2382
          @date=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2383
          foreach $y (@y) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2384
            foreach $m (@m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2385
              foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2386
                $date=&Date_Join($y,$m,$d,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2387
                push(@date,$date)  if ($d<29 || &Date_Split($date));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2388
              }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2389
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2390
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2391
          last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2392
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2393
        } elsif ($m eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2394
          # * Y-0-WOY-DOW-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2395
          # * Y-0-WOY-0-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2396
          @w=&ReturnList($w);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2397
          return ()  if (! @w);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2398
          foreach $w (@w) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2399
            return ()  if (! &IsInt($w,1,53));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2400
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2401
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2402
          if ($d eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2403
            @d=($Cnf{"FirstDay"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2404
          } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2405
            @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2406
            return ()  if (! @d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2407
            foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2408
              return ()  if (! &IsInt($d,1,7));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2409
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2410
            @d=sort { $a<=>$b } (@d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2411
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2412
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2413
          @date=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2414
          foreach $y (@y) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2415
            foreach $w (@w) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2416
              $w="0$w"  if (length($w)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2417
              foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2418
                $date=&ParseDateString("$y-W$w-$d");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2419
                push(@date,$date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2420
              }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2421
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2422
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2423
          last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2424
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2425
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2426
          # * Y-M-WOM-DOW-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2427
          # * Y-M-WOM-0-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2428
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2429
          @m=&ReturnList($m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2430
          return ()  if (! @m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2431
          foreach $m (@m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2432
            return ()  if (! &IsInt($m,1,12));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2433
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2434
          @m=sort { $a<=>$b } (@m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2435
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2436
          @w=&ReturnList($w);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2437
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2438
          if ($d eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2439
            @d=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2440
          } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2441
            @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2442
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2443
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2444
          @date=&Date_Recur_WoM(\@y,\@m,\@w,\@d,$MWn,$MDn);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2445
          last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2446
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2447
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2448
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2449
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2450
    if ($#recur0==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2451
      # Y * M-W-D-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2452
      $n=$y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2453
      $n=1  if ($n==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2454
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2455
      @m=&ReturnList($m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2456
      return ()  if (! @m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2457
      foreach $m (@m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2458
        return ()  if (! &IsInt($m,1,12));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2459
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2460
      @m=sort { $a<=>$b } (@m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2461
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2462
      if ($m eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2463
        # Y * 0-W-D-H-MN-S   (equiv to Y-0 * W-D-H-MN-S)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2464
        push(@recur0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2465
        shift(@recur1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2466
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2467
      } elsif ($w eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2468
        # Y * M-0-DOM-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2469
        return ()  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2470
        $d=1  if ($d eq "0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2471
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2472
        @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2473
        return ()  if (! @d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2474
        foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2475
          return ()  if (! &IsInt($d,1,31));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2476
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2477
        @d=sort { $a<=>$b } (@d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2478
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2479
        # We need to find years that are a multiple of $n from $y(base)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2480
        ($y0)=( &Date_Split($date0, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2481
        ($y1)=( &Date_Split($date1, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2482
        ($yb)=( &Date_Split($dateb, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2483
        @date=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2484
        for ($yy=$y0; $yy<=$y1; $yy++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2485
          if (($yy-$yb)%$n == 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2486
            foreach $m (@m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2487
              foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2488
                $date=&Date_Join($yy,$m,$d,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2489
                push(@date,$date)  if ($d<29 || &Date_Split($date));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2490
              }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2491
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2492
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2493
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2494
        last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2495
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2496
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2497
        # Y * M-WOM-DOW-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2498
        # Y * M-WOM-0-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2499
        return ()  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2500
        @m=&ReturnList($m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2501
        @w=&ReturnList($w);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2502
        if ($d eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2503
          @d=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2504
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2505
          @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2506
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2507
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2508
        ($y0)=( &Date_Split($date0, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2509
        ($y1)=( &Date_Split($date1, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2510
        ($yb)=( &Date_Split($dateb, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2511
        @y=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2512
        for ($yy=$y0; $yy<=$y1; $yy++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2513
          if (($yy-$yb)%$n == 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2514
            push(@y,$yy);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2515
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2516
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2517
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2518
        @date=&Date_Recur_WoM(\@y,\@m,\@w,\@d,$MWn,$MDn);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2519
        last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2520
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2521
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2522
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2523
    if ($#recur0==1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2524
      # Y-M * W-D-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2525
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2526
      if ($w eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2527
        # Y-M * 0-D-H-MN-S   (equiv to Y-M-0 * D-H-MN-S)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2528
        push(@recur0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2529
        shift(@recur1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2530
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2531
      } elsif ($m==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2532
        # Y-0 * WOY-0-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2533
        # Y-0 * WOY-DOW-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2534
        return ()  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2535
        $n=$y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2536
        $n=1  if ($n==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2537
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2538
        @w=&ReturnList($w);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2539
        return ()  if (! @w);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2540
        foreach $w (@w) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2541
          return ()  if (! &IsInt($w,1,53));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2542
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2543
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2544
        if ($d eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2545
          @d=($Cnf{"FirstDay"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2546
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2547
          @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2548
          return ()  if (! @d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2549
          foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2550
            return ()  if (! &IsInt($d,1,7));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2551
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2552
          @d=sort { $a<=>$b } (@d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2553
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2554
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2555
        # We need to find years that are a multiple of $n from $y(base)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2556
        ($y0)=( &Date_Split($date0, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2557
        ($y1)=( &Date_Split($date1, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2558
        ($yb)=( &Date_Split($dateb, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2559
        @date=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2560
        for ($yy=$y0; $yy<=$y1; $yy++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2561
          if (($yy-$yb)%$n == 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2562
            foreach $w (@w) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2563
              $w="0$w"  if (length($w)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2564
              foreach $tmp (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2565
                $date=&ParseDateString("$yy-W$w-$tmp");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2566
                push(@date,$date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2567
              }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2568
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2569
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2570
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2571
        last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2572
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2573
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2574
        # Y-M * WOM-0-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2575
        # Y-M * WOM-DOW-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2576
        return ()  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2577
        @tmp=(@recur0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2578
        push(@tmp,0)  while ($#tmp<6);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2579
        $delta=join(":",@tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2580
        @tmp=&Date_Recur($date0,$date1,$dateb,$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2581
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2582
        @w=&ReturnList($w);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2583
        @m=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2584
        if ($d eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2585
          @d=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2586
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2587
          @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2588
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2589
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2590
        @date=&Date_Recur_WoM(\@tmp,\@m,\@w,\@d,$MWn,$MDn);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2591
        last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2592
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2593
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2594
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2595
    if ($#recur0==2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2596
      # Y-M-W * D-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2597
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2598
      if ($d eq "0") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2599
        # Y-M-W * 0-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2600
        return ()  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2601
        $y=1  if ($y==0 && $m==0 && $w==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2602
        $delta="$y:$m:$w:0:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2603
        @date=&Date_Recur($date0,$date1,$dateb,$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2604
        last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2605
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2606
      } elsif ($m==0 && $w==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2607
        # Y-0-0 * DOY-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2608
        $y=1  if ($y==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2609
        $n=$y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2610
        return ()  if (! $dateb  &&  $y!=1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2611
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2612
        @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2613
        return ()  if (! @d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2614
        foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2615
          return ()  if (! &IsInt($d,1,366));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2616
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2617
        @d=sort { $a<=>$b } (@d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2618
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2619
        # We need to find years that are a multiple of $n from $y(base)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2620
        ($y0)=( &Date_Split($date0, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2621
        ($y1)=( &Date_Split($date1, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2622
        ($yb)=( &Date_Split($dateb, 1) )[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2623
        @date=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2624
        for ($yy=$y0; $yy<=$y1; $yy++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2625
          if (($yy-$yb)%$n == 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2626
            foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2627
              ($y,$m,$dd)=&Date_NthDayOfYear($yy,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2628
              push(@date, &Date_Join($y,$m,$dd,0,0,0));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2629
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2630
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2631
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2632
        last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2633
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2634
      } elsif ($w>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2635
        # Y-M-W * DOW-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2636
        return ()  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2637
        @tmp=(@recur0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2638
        push(@tmp,0)  while ($#tmp<6);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2639
        $delta=join(":",@tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2640
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2641
        @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2642
        return ()  if (! @d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2643
        foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2644
          return ()  if (! &IsInt($d,1,7));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2645
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2646
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2647
        # Find out what DofW the basedate is.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2648
        @tmp2=&Date_Split($dateb, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2649
        $tmp=&Date_DayOfWeek($tmp2[1],$tmp2[2],$tmp2[0]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2650
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2651
        @date=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2652
        foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2653
          $date_b=$dateb;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2654
          # Move basedate to DOW
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2655
          if ($d != $tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2656
            if (($tmp>=$Cnf{"FirstDay"} && $d<$Cnf{"FirstDay"}) ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2657
                ($tmp>=$Cnf{"FirstDay"} && $d>$tmp) ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2658
                ($tmp<$d && $d<$Cnf{"FirstDay"})) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2659
              $date_b=&Date_GetNext($date_b,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2660
            } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2661
              $date_b=&Date_GetPrev($date_b,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2662
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2663
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2664
          push(@date,&Date_Recur($date0,$date1,$date_b,$delta));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2665
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2666
        @date=sort(@date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2667
        last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2668
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2669
      } elsif ($m>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2670
        # Y-M-0 * DOM-H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2671
        return ()  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2672
        @tmp=(@recur0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2673
        push(@tmp,0)  while ($#tmp<6);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2674
        $delta=join(":",@tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2675
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2676
        @d=&ReturnList($d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2677
        return ()  if (! @d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2678
        foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2679
          return ()  if (! &IsInt($d,-31,31)  ||  $d==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2680
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2681
        @d=sort { $a<=>$b } (@d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2682
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2683
        @tmp2=&Date_Recur($date0,$date1,$dateb,$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2684
        @date=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2685
        foreach $date (@tmp2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2686
          ($y,$m)=( &Date_Split($date, 1) )[0..1];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2687
          $tmp2=&Date_DaysInMonth($m,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2688
          foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2689
            $d2=$d;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2690
            $d2=$tmp2+1+$d  if ($d<0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2691
            push(@date,&Date_Join($y,$m,$d2,0,0,0))  if ($d2<=$tmp2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2692
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2693
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2694
        @date=sort (@date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2695
        last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2696
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2697
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2698
        return ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2699
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2700
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2701
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2702
    if ($#recur0>2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2703
      # Y-M-W-D * H-MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2704
      # Y-M-W-D-H * MN-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2705
      # Y-M-W-D-H-MN * S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2706
      # Y-M-W-D-H-S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2707
      return ()  if (! $dateb);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2708
      @tmp=(@recur0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2709
      push(@tmp,0)  while ($#tmp<6);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2710
      $delta=join(":",@tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2711
      return ()  if ($delta !~ /[1-9]/);    # return if "0:0:0:0:0:0:0"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2712
      @date=&Date_Recur($date0,$date1,$dateb,$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2713
      if (@recur1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2714
        unshift(@recur1,-1)  while ($#recur1<2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2715
        @time=@recur1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2716
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2717
        shift(@date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2718
        pop(@date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2719
        @time=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2720
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2721
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2722
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2723
    last RECUR;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2724
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2725
  @date=&Date_RecurSetTime($date0,$date1,\@date,@time)  if (@time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2726
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2727
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2728
  # We've got a list of dates.  Operate on them with the flags.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2729
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2730
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2731
  my($sign,$forw,$today,$df,$db,$work,$i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2732
  if (@flags) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2733
  FLAG: foreach $f (@flags) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2734
      $f = uc($f);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2735
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2736
      if ($f =~ /^(P|N)(D|T)([1-7])$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2737
        @tmp=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2738
        $forw =($tmp[0] eq "P" ? 0 : 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2739
        $today=($tmp[1] eq "D" ? 0 : 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2740
        $d=$tmp[2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2741
        @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2742
        foreach $date (@date) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2743
          if ($forw) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2744
            push(@tmp, &Date_GetNext($date,$d,$today));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2745
          } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2746
            push(@tmp, &Date_GetPrev($date,$d,$today));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2747
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2748
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2749
        @date=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2750
        next FLAG;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2751
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2752
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2753
      # We want to go forward exact amounts of time instead of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2754
      # business mode calculations so that we don't change the time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2755
      # (which may have been set in the recur).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2756
      if ($f =~ /^(F|B)(D|W)(\d+)$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2757
        @tmp=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2758
        $sign="+";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2759
        $sign="-"  if ($tmp[0] eq "B");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2760
        $work=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2761
        $work=1    if ($tmp[1] eq "W");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2762
        $n=$tmp[2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2763
        @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2764
        foreach $date (@date) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2765
          for ($i=1; $i<=$n; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2766
            while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2767
              $date=&DateCalc($date,"${sign}0:0:0:1:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2768
              last if (! $work  ||  &Date_IsWorkDay($date,0));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2769
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2770
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2771
          push(@tmp,$date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2772
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2773
        @date=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2774
        next FLAG;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2775
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2776
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2777
      if ($f =~ /^CW(N|P|D)$/ || $f =~ /^(N|P|D)W(D)$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2778
        $tmp=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2779
        my $noalt = $2 ? 1 : 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2780
        if ($tmp eq "N"  ||  ($tmp eq "D" && $Cnf{"TomorrowFirst"})) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2781
          $forw=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2782
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2783
          $forw=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2784
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2785
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2786
        @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2787
      DATE: foreach $date (@date) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2788
          $df=$db=$date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2789
          if (&Date_IsWorkDay($date)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2790
            push(@tmp,$date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2791
            next DATE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2792
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2793
          while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2794
            if ($forw) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2795
              $d=$df=&DateCalc($df,"+0:0:0:1:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2796
            } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2797
              $d=$db=&DateCalc($db,"-0:0:0:1:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2798
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2799
            if (&Date_IsWorkDay($d)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2800
              push(@tmp,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2801
              next DATE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2802
            }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2803
            $forw=1-$forw  if (! $noalt);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2804
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2805
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2806
        @date=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2807
        next FLAG;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2808
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2809
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2810
      if ($f eq "EASTER") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2811
        @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2812
        foreach $date (@date) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2813
          ($y,$m,$d,$h,$mn,$s)=&Date_Split($date, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2814
          ($m,$d)=&Date_Easter($y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2815
          $date=&Date_Join($y,$m,$d,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2816
          next  if (&Date_Cmp($date,$date0)<0  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2817
                    &Date_Cmp($date,$date1)>0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2818
          push(@tmp,$date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2819
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2820
        @date=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2821
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2822
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2823
    @date = sort(@date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2824
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2825
  @date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2826
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2827
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2828
sub Date_GetPrev {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2829
  print "DEBUG: Date_GetPrev\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2830
  my($date,$dow,$today,$hr,$min,$sec)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2831
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2832
  my($y,$m,$d,$h,$mn,$s,$err,$curr_dow,%dow,$num,$delta,$th,$tm,$ts,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2833
     $adjust,$curr)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2834
  $hr="00"   if (defined $hr   &&  $hr eq "0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2835
  $min="00"  if (defined $min  &&  $min eq "0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2836
  $sec="00"  if (defined $sec  &&  $sec eq "0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2837
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2838
  if (! &Date_Split($date)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2839
    $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2840
    return ""  if (! $date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2841
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2842
  $curr=$date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2843
  ($y,$m,$d)=( &Date_Split($date, 1) )[0..2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2844
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2845
  if ($dow) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2846
    $curr_dow=&Date_DayOfWeek($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2847
    %dow=%{ $Lang{$Cnf{"Language"}}{"WeekH"} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2848
    if (&IsInt($dow)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2849
      return ""  if ($dow<1  ||  $dow>7);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2850
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2851
      return ""  if (! exists $dow{lc($dow)});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2852
      $dow=$dow{lc($dow)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2853
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2854
    if ($dow == $curr_dow) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2855
      $date=&DateCalc_DateDelta($date,"-0:0:1:0:0:0:0",\$err,0)  if (! $today);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2856
      $adjust=1  if ($today==2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2857
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2858
      $dow -= 7  if ($dow>$curr_dow); # make sure previous day is less
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2859
      $num = $curr_dow - $dow;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2860
      $date=&DateCalc_DateDelta($date,"-0:0:0:$num:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2861
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2862
    $date=&Date_SetTime($date,$hr,$min,$sec)  if (defined $hr);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2863
    $date=&DateCalc_DateDelta($date,"-0:0:1:0:0:0:0",\$err,0)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2864
      if ($adjust  &&  &Date_Cmp($date,$curr)>0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2865
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2866
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2867
    ($h,$mn,$s)=( &Date_Split($date, 1) )[3..5];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2868
    ($th,$tm,$ts)=&Date_ParseTime($hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2869
    if ($hr) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2870
      ($hr,$min,$sec)=($th,$tm,$ts);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2871
      $delta="-0:0:0:1:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2872
    } elsif ($min) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2873
      ($hr,$min,$sec)=($h,$tm,$ts);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2874
      $delta="-0:0:0:0:1:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2875
    } elsif ($sec) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2876
      ($hr,$min,$sec)=($h,$mn,$ts);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2877
      $delta="-0:0:0:0:0:1:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2878
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2879
      confess "ERROR: invalid arguments in Date_GetPrev.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2880
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2881
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2882
    $d=&Date_SetTime($date,$hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2883
    if ($today) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2884
      $d=&DateCalc_DateDelta($d,$delta,\$err,0)  if (&Date_Cmp($d,$date)>0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2885
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2886
      $d=&DateCalc_DateDelta($d,$delta,\$err,0)  if (&Date_Cmp($d,$date)>=0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2887
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2888
    $date=$d;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2889
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2890
  return $date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2891
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2892
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2893
sub Date_GetNext {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2894
  print "DEBUG: Date_GetNext\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2895
  my($date,$dow,$today,$hr,$min,$sec)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2896
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2897
  my($y,$m,$d,$h,$mn,$s,$err,$curr_dow,%dow,$num,$delta,$th,$tm,$ts,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2898
     $adjust,$curr)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2899
  $hr="00"   if (defined $hr   &&  $hr eq "0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2900
  $min="00"  if (defined $min  &&  $min eq "0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2901
  $sec="00"  if (defined $sec  &&  $sec eq "0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2902
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2903
  if (! &Date_Split($date)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2904
    $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2905
    return ""  if (! $date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2906
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2907
  $curr=$date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2908
  ($y,$m,$d)=( &Date_Split($date, 1) )[0..2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2909
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2910
  if ($dow) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2911
    $curr_dow=&Date_DayOfWeek($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2912
    %dow=%{ $Lang{$Cnf{"Language"}}{"WeekH"} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2913
    if (&IsInt($dow)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2914
      return ""  if ($dow<1  ||  $dow>7);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2915
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2916
      return ""  if (! exists $dow{lc($dow)});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2917
      $dow=$dow{lc($dow)};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2918
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2919
    if ($dow == $curr_dow) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2920
      $date=&DateCalc_DateDelta($date,"+0:0:1:0:0:0:0",\$err,0)  if (! $today);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2921
      $adjust=1  if ($today==2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2922
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2923
      $curr_dow -= 7  if ($curr_dow>$dow); # make sure next date is greater
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2924
      $num = $dow - $curr_dow;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2925
      $date=&DateCalc_DateDelta($date,"+0:0:0:$num:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2926
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2927
    $date=&Date_SetTime($date,$hr,$min,$sec)  if (defined $hr);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2928
    $date=&DateCalc_DateDelta($date,"+0:0:1:0:0:0:0",\$err,0)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2929
      if ($adjust  &&  &Date_Cmp($date,$curr)<0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2930
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2931
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2932
    ($h,$mn,$s)=( &Date_Split($date, 1) )[3..5];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2933
    ($th,$tm,$ts)=&Date_ParseTime($hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2934
    if ($hr) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2935
      ($hr,$min,$sec)=($th,$tm,$ts);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2936
      $delta="+0:0:0:1:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2937
    } elsif ($min) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2938
      ($hr,$min,$sec)=($h,$tm,$ts);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2939
      $delta="+0:0:0:0:1:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2940
    } elsif ($sec) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2941
      ($hr,$min,$sec)=($h,$mn,$ts);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2942
      $delta="+0:0:0:0:0:1:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2943
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2944
      confess "ERROR: invalid arguments in Date_GetNext.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2945
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2946
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2947
    $d=&Date_SetTime($date,$hr,$min,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2948
    if ($today) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2949
      $d=&DateCalc_DateDelta($d,$delta,\$err,0)  if (&Date_Cmp($d,$date)<0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2950
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2951
      $d=&DateCalc_DateDelta($d,$delta,\$err,0)  if (&Date_Cmp($d,$date)<1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2952
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2953
    $date=$d;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2954
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2955
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2956
  return $date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2957
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2958
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2959
sub Date_IsHoliday {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2960
  print "DEBUG: Date_IsHoliday\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2961
  my($date)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2962
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2963
  $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2964
  return undef  if (! $date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2965
  $date=&Date_SetTime($date,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2966
  my($y)=(&Date_Split($date, 1))[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2967
  &Date_UpdateHolidays($y)  if (! exists $Holiday{"dates"}{$y});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2968
  return undef  if (! exists $Holiday{"dates"}{$y}{$date});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2969
  my($name)=$Holiday{"dates"}{$y}{$date};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2970
  return ""   if (! $name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2971
  $name;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2972
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2973
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2974
sub Events_List {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2975
  print "DEBUG: Events_List\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2976
  my(@args)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2977
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2978
  &Events_ParseRaw();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2979
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2980
  my($tmp,$date0,$date1,$flag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2981
  $date0=&ParseDateString($args[0]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2982
  warn "Invalid date $args[0]", return undef  if (! $date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2983
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2984
  if ($#args == 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2985
    return &Events_Calc($date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2986
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2987
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2988
  if ($args[1]) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2989
    $date1=&ParseDateString($args[1]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2990
    warn "Invalid date $args[1]\n", return undef  if (! $date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2991
    if (&Date_Cmp($date0,$date1)>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2992
      $tmp=$date1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2993
      $date1=$date0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2994
      $date0=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2995
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2996
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2997
    $date0=&Date_SetTime($date0,"00:00:00");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2998
    $date1=&DateCalc_DateDelta($date0,"+0:0:0:1:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  2999
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3000
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3001
  $tmp=&Events_Calc($date0,$date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3002
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3003
  $flag=$args[2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3004
  return $tmp  if (! $flag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3005
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3006
  my(@tmp,%ret,$delta)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3007
  @tmp=@$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3008
  push(@tmp,$date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3009
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3010
  if ($flag==1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3011
    while ($#tmp>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3012
      ($date0,$tmp)=splice(@tmp,0,2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3013
      $date1=$tmp[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3014
      $delta=&DateCalc_DateDate($date0,$date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3015
      foreach $flag (@$tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3016
        if (exists $ret{$flag}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3017
          $ret{$flag}=&DateCalc_DeltaDelta($ret{$flag},$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3018
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3019
          $ret{$flag}=$delta;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3020
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3021
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3022
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3023
    return \%ret;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3024
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3025
  } elsif ($flag==2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3026
    while ($#tmp>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3027
      ($date0,$tmp)=splice(@tmp,0,2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3028
      $date1=$tmp[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3029
      $delta=&DateCalc_DateDate($date0,$date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3030
      $flag=join("+",sort @$tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3031
      next  if (! $flag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3032
      if (exists $ret{$flag}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3033
        $ret{$flag}=&DateCalc_DeltaDelta($ret{$flag},$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3034
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3035
        $ret{$flag}=$delta;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3036
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3037
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3038
    return \%ret;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3039
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3040
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3041
  warn "Invalid flag $flag\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3042
  return undef;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3043
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3044
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3045
###
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3046
# NOTE: The following routines may be called in the routines below with very
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3047
#       little time penalty.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3048
###
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3049
sub Date_SetTime {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3050
  print "DEBUG: Date_SetTime\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3051
  my($date,$h,$mn,$s)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3052
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3053
  my($y,$m,$d)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3054
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3055
  if (! &Date_Split($date)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3056
    $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3057
    return ""  if (! $date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3058
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3059
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3060
  ($y,$m,$d)=( &Date_Split($date, 1) )[0..2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3061
  ($h,$mn,$s)=&Date_ParseTime($h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3062
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3063
  my($ampm,$wk);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3064
  return ""  if (&Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3065
  &Date_Join($y,$m,$d,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3066
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3067
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3068
sub Date_SetDateField {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3069
  print "DEBUG: Date_SetDateField\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3070
  my($date,$field,$val,$nocheck)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3071
  my($y,$m,$d,$h,$mn,$s)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3072
  $nocheck=0  if (! defined $nocheck);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3073
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3074
  ($y,$m,$d,$h,$mn,$s)=&Date_Split($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3075
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3076
  if (! $y) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3077
    $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3078
    return "" if (! $date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3079
    ($y,$m,$d,$h,$mn,$s)=&Date_Split($date, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3080
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3081
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3082
  if      (lc($field) eq "y") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3083
    $y=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3084
  } elsif (lc($field) eq "m") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3085
    $m=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3086
  } elsif (lc($field) eq "d") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3087
    $d=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3088
  } elsif (lc($field) eq "h") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3089
    $h=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3090
  } elsif (lc($field) eq "mn") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3091
    $mn=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3092
  } elsif (lc($field) eq "s") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3093
    $s=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3094
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3095
    confess "ERROR: Date_SetDateField: invalid field: $field\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3096
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3097
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3098
  $date=&Date_Join($y,$m,$d,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3099
  return $date  if ($nocheck  ||  &Date_Split($date));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3100
  return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3101
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3102
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3103
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3104
# OTHER SUBROUTINES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3105
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3106
# NOTE: These routines should not call any of the routines above as
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3107
#       there will be a severe time penalty (and the possibility of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3108
#       infinite recursion).  The last couple routines above are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3109
#       exceptions.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3110
# NOTE: Date_Init is a special case.  It should be called (conditionally)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3111
#       in every routine that uses any variable from the Date::Manip
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3112
#       namespace.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3113
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3114
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3115
sub Date_DaysInMonth {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3116
  print "DEBUG: Date_DaysInMonth\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3117
  my($m,$y)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3118
  $y=&Date_FixYear($y)  if (length($y)!=4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3119
  my(@d_in_m)=(0,31,28,31,30,31,30,31,31,30,31,30,31);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3120
  $d_in_m[2]=29  if (&Date_LeapYear($y));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3121
  return $d_in_m[$m];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3122
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3123
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3124
sub Date_DayOfWeek {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3125
  print "DEBUG: Date_DayOfWeek\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3126
  my($m,$d,$y)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3127
  $y=&Date_FixYear($y)  if (length($y)!=4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3128
  my($dayofweek,$dec31)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3129
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3130
  $dec31=5;                     # Dec 31, 1BC was Friday
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3131
  $dayofweek=(&Date_DaysSince1BC($m,$d,$y)+$dec31) % 7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3132
  $dayofweek=7  if ($dayofweek==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3133
  return $dayofweek;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3134
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3135
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3136
# Can't be in "use integer" because the numbers are too big.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3137
no integer;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3138
sub Date_SecsSince1970 {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3139
  print "DEBUG: Date_SecsSince1970\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3140
  my($m,$d,$y,$h,$mn,$s)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3141
  $y=&Date_FixYear($y)  if (length($y)!=4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3142
  my($sec_now,$sec_70)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3143
  $sec_now=(&Date_DaysSince1BC($m,$d,$y)-1)*24*3600 + $h*3600 + $mn*60 + $s;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3144
# $sec_70 =(&Date_DaysSince1BC(1,1,1970)-1)*24*3600;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3145
  $sec_70 =62167219200;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3146
  return ($sec_now-$sec_70);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3147
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3148
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3149
sub Date_SecsSince1970GMT {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3150
  print "DEBUG: Date_SecsSince1970GMT\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3151
  my($m,$d,$y,$h,$mn,$s)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3152
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3153
  $y=&Date_FixYear($y)  if (length($y)!=4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3154
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3155
  my($sec)=&Date_SecsSince1970($m,$d,$y,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3156
  return $sec   if ($Cnf{"ConvTZ"} eq "IGNORE");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3157
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3158
  my($tz)=$Cnf{"ConvTZ"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3159
  $tz=$Cnf{"TZ"}  if (! $tz);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3160
  $tz=$Zone{"n2o"}{lc($tz)}  if ($tz !~ /^[+-]\d{4}$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3161
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3162
  my($tzs)=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3163
  $tzs=-1 if ($tz<0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3164
  $tz=~/.(..)(..)/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3165
  my($tzh,$tzm)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3166
  $sec - $tzs*($tzh*3600+$tzm*60);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3167
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3168
use integer;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3169
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3170
sub Date_DaysSince1BC {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3171
  print "DEBUG: Date_DaysSince1BC\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3172
  my($m,$d,$y)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3173
  $y=&Date_FixYear($y)  if (length($y)!=4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3174
  my($Ny,$N4,$N100,$N400,$dayofyear,$days)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3175
  my($cc,$yy)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3176
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3177
  $y=~ /(\d{2})(\d{2})/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3178
  ($cc,$yy)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3179
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3180
  # Number of full years since Dec 31, 1BC (counting the year 0000).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3181
  $Ny=$y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3182
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3183
  # Number of full 4th years (incl. 0000) since Dec 31, 1BC
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3184
  $N4=($Ny-1)/4 + 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3185
  $N4=0         if ($y==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3186
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3187
  # Number of full 100th years (incl. 0000)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3188
  $N100=$cc + 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3189
  $N100--       if ($yy==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3190
  $N100=0       if ($y==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3191
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3192
  # Number of full 400th years (incl. 0000)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3193
  $N400=($N100-1)/4 + 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3194
  $N400=0       if ($y==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3195
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3196
  $dayofyear=&Date_DayOfYear($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3197
  $days= $Ny*365 + $N4 - $N100 + $N400 + $dayofyear;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3198
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3199
  return $days;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3200
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3201
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3202
sub Date_DayOfYear {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3203
  print "DEBUG: Date_DayOfYear\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3204
  my($m,$d,$y)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3205
  $y=&Date_FixYear($y)  if (length($y)!=4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3206
  # DinM    = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3207
  my(@days) = ( 0, 31, 59, 90,120,151,181,212,243,273,304,334,365);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3208
  my($ly)=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3209
  $ly=1  if ($m>2 && &Date_LeapYear($y));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3210
  return ($days[$m-1]+$d+$ly);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3211
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3212
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3213
sub Date_DaysInYear {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3214
  print "DEBUG: Date_DaysInYear\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3215
  my($y)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3216
  $y=&Date_FixYear($y)  if (length($y)!=4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3217
  return 366  if (&Date_LeapYear($y));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3218
  return 365;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3219
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3220
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3221
sub Date_WeekOfYear {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3222
  print "DEBUG: Date_WeekOfYear\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3223
  my($m,$d,$y,$f)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3224
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3225
  $y=&Date_FixYear($y)  if (length($y)!=4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3226
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3227
  my($day,$dow,$doy)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3228
  $doy=&Date_DayOfYear($m,$d,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3229
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3230
  # The current DayOfYear and DayOfWeek
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3231
  if ($Cnf{"Jan1Week1"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3232
    $day=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3233
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3234
    $day=4;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3235
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3236
  $dow=&Date_DayOfWeek(1,$day,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3237
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3238
  # Move back to the first day of week 1.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3239
  $f-=7  if ($f>$dow);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3240
  $day-= ($dow-$f);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3241
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3242
  return 0  if ($day>$doy);      # Day is in last week of previous year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3243
  return (($doy-$day)/7 + 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3244
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3245
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3246
sub Date_LeapYear {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3247
  print "DEBUG: Date_LeapYear\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3248
  my($y)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3249
  $y=&Date_FixYear($y)  if (length($y)!=4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3250
  return 0 unless $y % 4 == 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3251
  return 1 unless $y % 100 == 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3252
  return 0 unless $y % 400 == 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3253
  return 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3254
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3255
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3256
sub Date_DaySuffix {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3257
  print "DEBUG: Date_DaySuffix\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3258
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3259
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3260
  return $Lang{$Cnf{"Language"}}{"DoML"}[$d-1];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3261
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3262
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3263
sub Date_ConvTZ {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3264
  print "DEBUG: Date_ConvTZ\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3265
  my($date,$from,$to)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3266
  if (not Date_Split($date)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3267
      croak "date passed in ('$date') is not a Date::Manip object";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3268
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3269
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3270
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3271
  my($gmt)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3272
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3273
  if (! $from) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3274
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3275
    if (! $to) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3276
      # TZ -> ConvTZ
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3277
      return $date  if ($Cnf{"ConvTZ"} eq "IGNORE" or ! $Cnf{"ConvTZ"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3278
      $from=$Cnf{"TZ"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3279
      $to=$Cnf{"ConvTZ"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3280
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3281
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3282
      # ConvTZ,TZ -> $to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3283
      $from=$Cnf{"ConvTZ"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3284
      $from=$Cnf{"TZ"}  if (! $from);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3285
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3286
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3287
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3288
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3289
    if (! $to) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3290
      # $from -> ConvTZ,TZ
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3291
      return $date  if ($Cnf{"ConvTZ"} eq "IGNORE");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3292
      $to=$Cnf{"ConvTZ"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3293
      $to=$Cnf{"TZ"}  if (! $to);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3294
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3295
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3296
      # $from -> $to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3297
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3298
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3299
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3300
  $to=$Zone{"n2o"}{lc($to)}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3301
    if (exists $Zone{"n2o"}{lc($to)});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3302
  $from=$Zone{"n2o"}{lc($from)}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3303
    if (exists $Zone{"n2o"}{lc($from)});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3304
  $gmt=$Zone{"n2o"}{"gmt"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3305
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3306
  return $date  if ($from !~ /^[+-]\d{4}$/ or $to !~ /^[+-]\d{4}$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3307
  return $date  if ($from eq $to);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3308
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3309
  my($s1,$h1,$m1,$s2,$h2,$m2,$d,$h,$m,$sign,$delta,$err,$yr,$mon,$sec)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3310
  # We're going to try to do the calculation without calling DateCalc.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3311
  ($yr,$mon,$d,$h,$m,$sec)=&Date_Split($date, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3312
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3313
  # Convert $date from $from to GMT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3314
  $from=~/([+-])(\d{2})(\d{2})/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3315
  ($s1,$h1,$m1)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3316
  $s1= ($s1 eq "-" ? "+" : "-");   # switch sign
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3317
  $sign=$s1 . "1";     # + or - 1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3318
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3319
  # and from GMT to $to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3320
  $to=~/([+-])(\d{2})(\d{2})/;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3321
  ($s2,$h2,$m2)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3322
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3323
  if ($s1 eq $s2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3324
    # Both the same sign
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3325
    $m+= $sign*($m1+$m2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3326
    $h+= $sign*($h1+$h2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3327
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3328
    $sign=($s2 eq "-" ? +1 : -1)  if ($h1<$h2  ||  ($h1==$h2 && $m1<$m2));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3329
    $m+= $sign*($m1-$m2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3330
    $h+= $sign*($h1-$h2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3331
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3332
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3333
  if ($m>59) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3334
    $h+= $m/60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3335
    $m-= ($m/60)*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3336
  } elsif ($m<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3337
    $h+= ($m/60 - 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3338
    $m-= ($m/60 - 1)*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3339
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3340
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3341
  if ($h>23) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3342
    $delta=$h/24;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3343
    $h -= $delta*24;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3344
    if (($d + $delta) > 28) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3345
      $date=&Date_Join($yr,$mon,$d,$h,$m,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3346
      return &DateCalc_DateDelta($date,"+0:0:0:$delta:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3347
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3348
    $d+= $delta;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3349
  } elsif ($h<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3350
    $delta=-$h/24 + 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3351
    $h += $delta*24;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3352
    if (($d - $delta) < 1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3353
      $date=&Date_Join($yr,$mon,$d,$h,$m,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3354
      return &DateCalc_DateDelta($date,"-0:0:0:$delta:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3355
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3356
    $d-= $delta;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3357
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3358
  return &Date_Join($yr,$mon,$d,$h,$m,$sec);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3359
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3360
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3361
sub Date_TimeZone {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3362
  print "DEBUG: Date_TimeZone\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3363
  my($null,$tz,@tz,$std,$dst,$time,$isdst,$tmp,$in)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3364
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3365
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3366
  # Get timezones from all of the relevant places
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3367
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3368
  push(@tz,$Cnf{"TZ"})  if (defined $Cnf{"TZ"});  # TZ config var
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3369
  push(@tz,$ENV{"TZ"})  if (defined $ENV{"TZ"});  # TZ environ var
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3370
  push(@tz,$ENV{'SYS$TIMEZONE_RULE'})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3371
    if defined $ENV{'SYS$TIMEZONE_RULE'};         # VMS TZ environ var
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3372
  push(@tz,$ENV{'SYS$TIMEZONE_NAME'})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3373
    if defined $ENV{'SYS$TIMEZONE_NAME'};         # VMS TZ name environ var
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3374
  push(@tz,$ENV{'UCX$TZ'})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3375
    if defined $ENV{'UCX$TZ'};                    # VMS TZ environ var
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3376
  push(@tz,$ENV{'TCPIP$TZ'})
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3377
    if defined $ENV{'TCPIP$TZ'};                  # VMS TZ environ var
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3378
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3379
  # The `date` command... if we're doing taint checking, we need to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3380
  # always call it with a full path... otherwise, use the user's path.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3381
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3382
  # Microsoft operating systems don't have a date command built in.  Try
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3383
  # to trap all the various ways of knowing we are on one of these systems.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3384
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3385
  # We'll try `date +%Z` first, and if that fails, we'll take just the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3386
  # `date` program and assume the output is of the format:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3387
  # Thu Aug 31 14:57:46 EDT 2000
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3388
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3389
  unless (($^X =~ /perl\.exe$/i) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3390
          ($OS eq "Windows") or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3391
          ($OS eq "Netware") or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3392
          ($OS eq "VMS")) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3393
    if ($Date::Manip::NoTaint) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3394
      if ($OS eq "VMS") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3395
        $tz=$ENV{'SYS$TIMEZONE_NAME'};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3396
        if (! $tz) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3397
          $tz=$ENV{'MULTINET_TIMEZONE'};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3398
          if (! $tz) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3399
            $tz=$ENV{'SYS$TIMEZONE_DIFFERENTIAL'}/3600.; # e.g. '-4' for EDT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3400
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3401
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3402
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3403
        $tz=`date +%Z 2> /dev/null`;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3404
        chomp($tz);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3405
        if (! $tz) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3406
          $tz=`date 2> /dev/null`;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3407
          chomp($tz);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3408
          $tz=(split(/\s+/,$tz))[4];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3409
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3410
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3411
      push(@tz,$tz);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3412
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3413
      # We need to satisfy taint checking, but also look in all the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3414
      # directories in @DatePath.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3415
      #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3416
      local $ENV{PATH} = join(':', @Date::Manip::DatePath);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3417
      local $ENV{BASH_ENV} = '';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3418
      $tz=`date +%Z 2> /dev/null`;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3419
      chomp($tz);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3420
      if (! $tz) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3421
	$tz=`date 2> /dev/null`;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3422
	chomp($tz);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3423
	$tz=(split(/\s+/,$tz))[4];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3424
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3425
      push(@tz,$tz);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3426
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3427
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3428
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3429
  push(@tz,$main::TZ)         if (defined $main::TZ);         # $main::TZ
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3430
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3431
  if (-s "/etc/TIMEZONE") {                                   # /etc/TIMEZONE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3432
    $in=new IO::File;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3433
    $in->open("/etc/TIMEZONE","r");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3434
    while (! eof($in)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3435
      $tmp=<$in>;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3436
      if ($tmp =~ /^TZ\s*=\s*(.*?)\s*$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3437
        push(@tz,$1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3438
        last;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3439
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3440
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3441
    $in->close;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3442
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3443
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3444
  if (-s "/etc/timezone") {                                   # /etc/timezone
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3445
    $in=new IO::File;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3446
    $in->open("/etc/timezone","r");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3447
    while (! eof($in)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3448
      $tmp=<$in>;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3449
      next  if ($tmp =~ /^\s*\043/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3450
      chomp($tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3451
      if ($tmp =~ /^\s*(.*?)\s*$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3452
        push(@tz,$1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3453
        last;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3454
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3455
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3456
    $in->close;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3457
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3458
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3459
  # Now parse each one to find the first valid one.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3460
  foreach $tz (@tz) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3461
    $tz =~ s/\s*$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3462
    $tz =~ s/^\s*//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3463
    next  if (! $tz);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3464
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3465
    return uc($tz)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3466
      if (defined $Zone{"n2o"}{lc($tz)});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3467
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3468
    if ($tz =~ /^[+-]\d{4}$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3469
      return $tz;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3470
    } elsif ($tz =~ /^([+-]\d{2})(?::(\d{2}))?$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3471
      my($h,$m)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3472
      $m="00"  if (! $m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3473
      return "$h$m";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3474
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3475
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3476
    # Handle US/Eastern format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3477
    if ($tz =~ /^$Zone{"tzones"}$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3478
      $tmp=lc $1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3479
      $tz=$Zone{"tz2z"}{$tmp};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3480
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3481
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3482
    # Handle STD#DST# format (and STD-#DST-# formats)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3483
    if ($tz =~ /^([a-z]+)-?\d([a-z]+)-?\d?$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3484
      ($std,$dst)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3485
      next  if (! defined $Zone{"n2o"}{lc($std)} or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3486
                ! defined $Zone{"n2o"}{lc($dst)});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3487
      $time = time();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3488
      ($null,$null,$null,$null,$null,$null,$null,$null,$isdst) =
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3489
        localtime($time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3490
      return uc($dst)  if ($isdst);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3491
      return uc($std);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3492
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3493
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3494
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3495
  confess "ERROR: Date::Manip unable to determine TimeZone.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3496
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3497
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3498
# Returns 1 if $date is a work day.  If $time is non-zero, the time is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3499
# also checked to see if it falls within work hours.  Returns "" if
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3500
# an invalid date is passed in.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3501
sub Date_IsWorkDay {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3502
  print "DEBUG: Date_IsWorkDay\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3503
  my($date,$time)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3504
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3505
  $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3506
  return ""  if (! $date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3507
  my($d)=$date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3508
  $d=&Date_SetTime($date,$Cnf{"WorkDayBeg"})  if (! $time);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3509
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3510
  my($y,$mon,$day,$tmp,$h,$m,$dow)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3511
  ($y,$mon,$day,$h,$m,$tmp)=&Date_Split($d, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3512
  $dow=&Date_DayOfWeek($mon,$day,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3513
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3514
  return 0  if ($dow<$Cnf{"WorkWeekBeg"} or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3515
                $dow>$Cnf{"WorkWeekEnd"} or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3516
                "$h:$m" lt $Cnf{"WorkDayBeg"} or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3517
                "$h:$m" gt $Cnf{"WorkDayEnd"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3518
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3519
  if (! exists $Holiday{"dates"}{$y}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3520
    # There will be recursion problems if we ever end up here twice.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3521
    $Holiday{"dates"}{$y}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3522
    &Date_UpdateHolidays($y)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3523
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3524
  $d=&Date_SetTime($date,"00:00:00");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3525
  return 0  if (exists $Holiday{"dates"}{$y}{$d});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3526
  1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3527
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3528
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3529
# Finds the day $off work days from now.  If $time is passed in, we must
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3530
# also take into account the time of day.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3531
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3532
# If $time is not passed in, day 0 is today (if today is a workday) or the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3533
# next work day if it isn't.  In any case, the time of day is unaffected.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3534
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3535
# If $time is passed in, day 0 is now (if now is part of a workday) or the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3536
# start of the very next work day.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3537
sub Date_NextWorkDay {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3538
  print "DEBUG: Date_NextWorkDay\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3539
  my($date,$off,$time)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3540
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3541
  $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3542
  my($err)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3543
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3544
  if (! &Date_IsWorkDay($date,$time)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3545
    if ($time) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3546
      while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3547
        $date=&Date_GetNext($date,undef,0,$Cnf{"WorkDayBeg"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3548
        last  if (&Date_IsWorkDay($date,$time));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3549
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3550
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3551
      while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3552
        $date=&DateCalc_DateDelta($date,"+0:0:0:1:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3553
        last  if (&Date_IsWorkDay($date,$time));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3554
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3555
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3556
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3557
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3558
  while ($off>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3559
    while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3560
      $date=&DateCalc_DateDelta($date,"+0:0:0:1:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3561
      last  if (&Date_IsWorkDay($date,$time));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3562
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3563
    $off--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3564
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3565
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3566
  return $date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3567
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3568
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3569
# Finds the day $off work days before now.  If $time is passed in, we must
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3570
# also take into account the time of day.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3571
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3572
# If $time is not passed in, day 0 is today (if today is a workday) or the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3573
# previous work day if it isn't.  In any case, the time of day is unaffected.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3574
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3575
# If $time is passed in, day 0 is now (if now is part of a workday) or the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3576
# end of the previous work period.  Note that since the end of a work day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3577
# will automatically be turned into the start of the next one, this time
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3578
# may actually be treated as AFTER the current time.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3579
sub Date_PrevWorkDay {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3580
  print "DEBUG: Date_PrevWorkDay\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3581
  my($date,$off,$time)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3582
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3583
  $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3584
  my($err)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3585
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3586
  if (! &Date_IsWorkDay($date,$time)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3587
    if ($time) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3588
      while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3589
        $date=&Date_GetPrev($date,undef,0,$Cnf{"WorkDayEnd"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3590
        last  if (&Date_IsWorkDay($date,$time));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3591
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3592
      while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3593
        $date=&Date_GetNext($date,undef,0,$Cnf{"WorkDayBeg"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3594
        last  if (&Date_IsWorkDay($date,$time));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3595
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3596
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3597
      while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3598
        $date=&DateCalc_DateDelta($date,"-0:0:0:1:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3599
        last  if (&Date_IsWorkDay($date,$time));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3600
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3601
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3602
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3603
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3604
  while ($off>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3605
    while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3606
      $date=&DateCalc_DateDelta($date,"-0:0:0:1:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3607
      last  if (&Date_IsWorkDay($date,$time));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3608
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3609
    $off--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3610
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3611
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3612
  return $date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3613
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3614
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3615
# This finds the nearest workday to $date.  If $date is a workday, it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3616
# is returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3617
sub Date_NearestWorkDay {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3618
  print "DEBUG: Date_NearestWorkDay\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3619
  my($date,$tomorrow)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3620
  &Date_Init()  if (! $Curr{"InitDone"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3621
  $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3622
  my($a,$b,$dela,$delb,$err)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3623
  $tomorrow=$Cnf{"TomorrowFirst"}  if (! defined $tomorrow);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3624
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3625
  return $date  if (&Date_IsWorkDay($date));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3626
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3627
  # Find the nearest one.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3628
  if ($tomorrow) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3629
    $dela="+0:0:0:1:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3630
    $delb="-0:0:0:1:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3631
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3632
    $dela="-0:0:0:1:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3633
    $delb="+0:0:0:1:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3634
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3635
  $a=$b=$date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3636
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3637
  while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3638
    $a=&DateCalc_DateDelta($a,$dela,\$err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3639
    return $a  if (&Date_IsWorkDay($a));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3640
    $b=&DateCalc_DateDelta($b,$delb,\$err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3641
    return $b  if (&Date_IsWorkDay($b));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3642
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3643
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3644
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3645
# &Date_NthDayOfYear($y,$n);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3646
#   Returns a list of (YYYY,MM,DD,HH,MM,SS) for the Nth day of the year.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3647
sub Date_NthDayOfYear {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3648
  no integer;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3649
  print "DEBUG: Date_NthDayOfYear\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3650
  my($y,$n)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3651
  $y=$Curr{"Y"}  if (! $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3652
  $n=1       if (! defined $n  or  $n eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3653
  $n+=0;     # to turn 023 into 23
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3654
  $y=&Date_FixYear($y)  if (length($y)<4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3655
  my $leap=&Date_LeapYear($y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3656
  return ()  if ($n<1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3657
  return ()  if ($n >= ($leap ? 367 : 366));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3658
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3659
  my(@d_in_m)=(31,28,31,30,31,30,31,31,30,31,30,31);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3660
  $d_in_m[1]=29  if ($leap);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3661
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3662
  # Calculate the hours, minutes, and seconds into the day.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3663
  my $remain=($n - int($n))*24;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3664
  my $h=int($remain);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3665
  $remain=($remain - $h)*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3666
  my $mn=int($remain);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3667
  $remain=($remain - $mn)*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3668
  my $s=$remain;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3669
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3670
  # Calculate the month and the day.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3671
  my($m,$d)=(0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3672
  $n=int($n);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3673
  while ($n>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3674
    $m++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3675
    if ($n<=$d_in_m[0]) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3676
      $d=int($n);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3677
      $n=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3678
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3679
      $n-= $d_in_m[0];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3680
      shift(@d_in_m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3681
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3682
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3683
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3684
  ($y,$m,$d,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3685
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3686
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3687
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3688
# NOT FOR EXPORT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3689
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3690
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3691
# This is used in Date_Init to fill in a hash based on international
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3692
# data.  It takes a list of keys and values and returns both a hash
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3693
# with these values and a regular expression of keys.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3694
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3695
# IN:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3696
#   $data   = [ key1 val1 key2 val2 ... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3697
#   $opts   = lc     : lowercase the keys in the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3698
#             sort   : sort (by length) the keys in the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3699
#             back   : create a regexp with a back reference
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3700
#             escape : escape all strings in the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3701
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3702
# OUT:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3703
#   $regexp = '(?:key1|key2|...)'
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3704
#   $hash   = { key1=>val1 key2=>val2 ... }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3705
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3706
sub Date_InitHash {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3707
  print "DEBUG: Date_InitHash\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3708
  my($data,$regexp,$opts,$hash)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3709
  my(@data)=@$data;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3710
  my($key,$val,@list)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3711
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3712
  # Parse the options
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3713
  my($lc,$sort,$back,$escape)=(0,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3714
  $lc=1     if ($opts =~ /lc/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3715
  $sort=1   if ($opts =~ /sort/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3716
  $back=1   if ($opts =~ /back/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3717
  $escape=1 if ($opts =~ /escape/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3718
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3719
  # Create the hash
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3720
  while (@data) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3721
    ($key,$val,@data)=@data;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3722
    $key=lc($key)  if ($lc);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3723
    $$hash{$key}=$val;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3724
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3725
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3726
  # Create the regular expression
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3727
  if ($regexp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3728
    @list=keys(%$hash);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3729
    @list=sort sortByLength(@list)  if ($sort);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3730
    if ($escape) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3731
      foreach $val (@list) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3732
        $val="\Q$val\E";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3733
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3734
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3735
    if ($back) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3736
      $$regexp="(" . join("|",@list) . ")";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3737
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3738
      $$regexp="(?:" . join("|",@list) . ")";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3739
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3740
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3741
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3742
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3743
# This is used in Date_Init to fill in regular expressions, lists, and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3744
# hashes based on international data.  It takes a list of lists which have
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3745
# to be stored as regular expressions (to find any element in the list),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3746
# lists, and hashes (indicating the location in the lists).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3747
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3748
# IN:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3749
#   $data   = [ [ [ valA1 valA2 ... ][ valA1' valA2' ... ] ... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3750
#               [ [ valB1 valB2 ... ][ valB1' valB2' ... ] ... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3751
#               ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3752
#               [ [ valZ1 valZ2 ... ] [valZ1' valZ1' ... ] ... ] ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3753
#   $lists  = [ \@listA \@listB ... \@listZ ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3754
#   $opts   = lc     : lowercase the values in the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3755
#             sort   : sort (by length) the values in the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3756
#             back   : create a regexp with a back reference
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3757
#             escape : escape all strings in the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3758
#   $hash   = [ \%hash, TYPE ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3759
#             TYPE 0 : $hash{ valBn=>n-1 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3760
#             TYPE 1 : $hash{ valBn=>n }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3761
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3762
# OUT:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3763
#   $regexp = '(?:valA1|valA2|...|valB1|...)'
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3764
#   $lists  = [ [ valA1 valA2 ... ]         # only the 1st list (or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3765
#               [ valB1 valB2 ... ] ... ]   # 2nd for int. characters)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3766
#   $hash
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3767
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3768
sub Date_InitLists {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3769
  print "DEBUG: Date_InitLists\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3770
  my($data,$regexp,$opts,$lists,$hash)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3771
  my(@data)=@$data;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3772
  my(@lists)=@$lists;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3773
  my($i,@ele,$ele,@list,$j,$tmp)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3774
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3775
  # Parse the options
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3776
  my($lc,$sort,$back,$escape)=(0,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3777
  $lc=1     if ($opts =~ /lc/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3778
  $sort=1   if ($opts =~ /sort/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3779
  $back=1   if ($opts =~ /back/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3780
  $escape=1 if ($opts =~ /escape/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3781
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3782
  # Set each of the lists
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3783
  if (@lists) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3784
    confess "ERROR: Date_InitLists: lists must be 1 per data\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3785
      if ($#lists != $#data);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3786
    for ($i=0; $i<=$#data; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3787
      @ele=@{ $data[$i] };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3788
      if ($Cnf{"IntCharSet"} && $#ele>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3789
        @{ $lists[$i] } = @{ $ele[1] };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3790
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3791
        @{ $lists[$i] } = @{ $ele[0] };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3792
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3793
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3794
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3795
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3796
  # Create the hash
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3797
  my($hashtype,$hashsave,%hash)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3798
  if (@$hash) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3799
    ($hash,$hashtype)=@$hash;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3800
    $hashsave=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3801
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3802
    $hashtype=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3803
    $hashsave=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3804
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3805
  for ($i=0; $i<=$#data; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3806
    @ele=@{ $data[$i] };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3807
    foreach $ele (@ele) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3808
      @list = @{ $ele };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3809
      for ($j=0; $j<=$#list; $j++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3810
        $tmp=$list[$j];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3811
        next  if (! $tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3812
        $tmp=lc($tmp)  if ($lc);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3813
        $hash{$tmp}= $j+$hashtype;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3814
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3815
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3816
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3817
  %$hash = %hash  if ($hashsave);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3818
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3819
  # Create the regular expression
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3820
  if ($regexp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3821
    @list=keys(%hash);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3822
    @list=sort sortByLength(@list)  if ($sort);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3823
    if ($escape) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3824
      foreach $ele (@list) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3825
        $ele="\Q$ele\E";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3826
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3827
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3828
    if ($back) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3829
      $$regexp="(" . join("|",@list) . ")";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3830
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3831
      $$regexp="(?:" . join("|",@list) . ")";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3832
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3833
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3834
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3835
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3836
# This is used in Date_Init to fill in regular expressions and lists based
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3837
# on international data.  This takes a list of strings and returns a regular
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3838
# expression (to find any one of them).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3839
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3840
# IN:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3841
#   $data   = [ string1 string2 ... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3842
#   $opts   = lc     : lowercase the values in the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3843
#             sort   : sort (by length) the values in the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3844
#             back   : create a regexp with a back reference
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3845
#             escape : escape all strings in the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3846
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3847
# OUT:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3848
#   $regexp = '(string1|string2|...)'
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3849
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3850
sub Date_InitStrings {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3851
  print "DEBUG: Date_InitStrings\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3852
  my($data,$regexp,$opts)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3853
  my(@list)=@{ $data };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3854
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3855
  # Parse the options
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3856
  my($lc,$sort,$back,$escape)=(0,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3857
  $lc=1     if ($opts =~ /lc/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3858
  $sort=1   if ($opts =~ /sort/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3859
  $back=1   if ($opts =~ /back/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3860
  $escape=1 if ($opts =~ /escape/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3861
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3862
  # Create the regular expression
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3863
  my($ele)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3864
  @list=sort sortByLength(@list)  if ($sort);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3865
  if ($escape) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3866
    foreach $ele (@list) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3867
      $ele="\Q$ele\E";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3868
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3869
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3870
  if ($back) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3871
    $$regexp="(" . join("|",@list) . ")";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3872
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3873
    $$regexp="(?:" . join("|",@list) . ")";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3874
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3875
  $$regexp=lc($$regexp)  if ($lc);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3876
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3877
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3878
# items is passed in (either as a space separated string, or a reference to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3879
# a list) and a regular expression which matches any one of the items is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3880
# prepared.  The regular expression will be of one of the forms:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3881
#   "(a|b)"       @list not empty, back option included
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3882
#   "(?:a|b)"     @list not empty
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3883
#   "()"          @list empty,     back option included
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3884
#   ""            @list empty
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3885
# $options is a string which contains any of the following strings:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3886
#   back     : the regular expression has a backreference
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3887
#   opt      : the regular expression is optional and a "?" is appended in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3888
#              the first two forms
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3889
#   optws    : the regular expression is optional and may be replaced by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3890
#              whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3891
#   optWs    : the regular expression is optional, but if not present, must
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3892
#              be replaced by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3893
#   sort     : the items in the list are sorted by length (longest first)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3894
#   lc       : the string is lowercased
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3895
#   under    : any underscores are converted to spaces
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3896
#   pre      : it may be preceded by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3897
#   Pre      : it must be preceded by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3898
#   PRE      : it must be preceded by whitespace or the start
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3899
#   post     : it may be followed by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3900
#   Post     : it must be followed by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3901
#   POST     : it must be followed by whitespace or the end
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3902
# Spaces due to pre/post options will not be included in the back reference.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3903
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3904
# If $array is included, then the elements will also be returned as a list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3905
# $array is a string which may contain any of the following:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3906
#   keys     : treat the list as a hash and only the keys go into the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3907
#   key0     : treat the list as the values of a hash with keys 0 .. N-1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3908
#   key1     : treat the list as the values of a hash with keys 1 .. N
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3909
#   val0     : treat the list as the keys of a hash with values 0 .. N-1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3910
#   val1     : treat the list as the keys of a hash with values 1 .. N
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3911
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3912
#    &Date_InitLists([$lang{"month_name"},$lang{"month_abb"}],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3913
#             [\$Month,"lc,sort,back"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3914
#             [\@Month,\@Mon],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3915
#             [\%Month,1]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3916
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3917
# This is used in Date_Init to prepare regular expressions.  A list of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3918
# items is passed in (either as a space separated string, or a reference to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3919
# a list) and a regular expression which matches any one of the items is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3920
# prepared.  The regular expression will be of one of the forms:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3921
#   "(a|b)"       @list not empty, back option included
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3922
#   "(?:a|b)"     @list not empty
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3923
#   "()"          @list empty,     back option included
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3924
#   ""            @list empty
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3925
# $options is a string which contains any of the following strings:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3926
#   back     : the regular expression has a backreference
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3927
#   opt      : the regular expression is optional and a "?" is appended in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3928
#              the first two forms
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3929
#   optws    : the regular expression is optional and may be replaced by
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3930
#              whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3931
#   optWs    : the regular expression is optional, but if not present, must
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3932
#              be replaced by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3933
#   sort     : the items in the list are sorted by length (longest first)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3934
#   lc       : the string is lowercased
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3935
#   under    : any underscores are converted to spaces
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3936
#   pre      : it may be preceded by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3937
#   Pre      : it must be preceded by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3938
#   PRE      : it must be preceded by whitespace or the start
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3939
#   post     : it may be followed by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3940
#   Post     : it must be followed by whitespace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3941
#   POST     : it must be followed by whitespace or the end
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3942
# Spaces due to pre/post options will not be included in the back reference.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3943
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3944
# If $array is included, then the elements will also be returned as a list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3945
# $array is a string which may contain any of the following:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3946
#   keys     : treat the list as a hash and only the keys go into the regexp
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3947
#   key0     : treat the list as the values of a hash with keys 0 .. N-1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3948
#   key1     : treat the list as the values of a hash with keys 1 .. N
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3949
#   val0     : treat the list as the keys of a hash with values 0 .. N-1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3950
#   val1     : treat the list as the keys of a hash with values 1 .. N
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3951
sub Date_Regexp {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3952
  print "DEBUG: Date_Regexp\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3953
  my($list,$options,$array)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3954
  my(@list,$ret,%hash,$i)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3955
  local($_)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3956
  $options=""  if (! defined $options);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3957
  $array=""    if (! defined $array);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3958
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3959
  my($sort,$lc,$under)=(0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3960
  $sort =1  if ($options =~ /sort/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3961
  $lc   =1  if ($options =~ /lc/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3962
  $under=1  if ($options =~ /under/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3963
  my($back,$opt,$pre,$post,$ws)=("?:","","","","");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3964
  $back =""          if ($options =~ /back/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3965
  $opt  ="?"         if ($options =~ /opt/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3966
  $pre  ='\s*'       if ($options =~ /pre/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3967
  $pre  ='\s+'       if ($options =~ /Pre/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3968
  $pre  ='(?:\s+|^)' if ($options =~ /PRE/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3969
  $post ='\s*'       if ($options =~ /post/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3970
  $post ='\s+'       if ($options =~ /Post/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3971
  $post ='(?:$|\s+)' if ($options =~ /POST/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3972
  $ws   ='\s*'       if ($options =~ /optws/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3973
  $ws   ='\s+'       if ($options =~ /optws/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3974
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3975
  my($hash,$keys,$key0,$key1,$val0,$val1)=(0,0,0,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3976
  $keys =1     if ($array =~ /keys/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3977
  $key0 =1     if ($array =~ /key0/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3978
  $key1 =1     if ($array =~ /key1/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3979
  $val0 =1     if ($array =~ /val0/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3980
  $val1 =1     if ($array =~ /val1/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3981
  $hash =1     if ($keys or $key0 or $key1 or $val0 or $val1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3982
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3983
  my($ref)=ref $list;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3984
  if (! $ref) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3985
    $list =~ s/\s*$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3986
    $list =~ s/^\s*//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3987
    $list =~ s/\s+/&&&/g;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3988
  } elsif ($ref eq "ARRAY") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3989
    $list = join("&&&",@$list);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3990
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3991
    confess "ERROR: Date_Regexp.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3992
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3993
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3994
  if (! $list) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3995
    if ($back eq "") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3996
      return "()";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3997
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3998
      return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  3999
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4000
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4001
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4002
  $list=lc($list)  if ($lc);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4003
  $list=~ s/_/ /g  if ($under);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4004
  @list=split(/&&&/,$list);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4005
  if ($keys) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4006
    %hash=@list;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4007
    @list=keys %hash;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4008
  } elsif ($key0 or $key1 or $val0 or $val1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4009
    $i=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4010
    $i=1  if ($key1 or $val1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4011
    if ($key0 or $key1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4012
      %hash= map { $_,$i++ } @list;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4013
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4014
      %hash= map { $i++,$_ } @list;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4015
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4016
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4017
  @list=sort sortByLength(@list)  if ($sort);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4018
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4019
  $ret="($back" . join("|",@list) . ")";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4020
  $ret="(?:$pre$ret$post)"  if ($pre or $post);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4021
  $ret.=$opt;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4022
  $ret="(?:$ret|$ws)"  if ($ws);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4023
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4024
  if ($array and $hash) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4025
    return ($ret,%hash);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4026
  } elsif ($array) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4027
    return ($ret,@list);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4028
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4029
    return $ret;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4030
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4031
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4032
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4033
# This will produce a delta with the correct number of signs.  At most two
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4034
# signs will be in it normally (one before the year, and one in front of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4035
# the day), but if appropriate, signs will be in front of all elements.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4036
# Also, as many of the signs will be equivalent as possible.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4037
sub Delta_Normalize {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4038
  print "DEBUG: Delta_Normalize\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4039
  my($delta,$mode)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4040
  return "" if (! $delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4041
  return "+0:+0:+0:+0:+0:+0:+0"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4042
    if ($delta =~ /^([+-]?0+:){6}[+-]?0+$/ and $Cnf{"DeltaSigns"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4043
  return "+0:0:0:0:0:0:0" if ($delta =~ /^([+-]?0+:){6}[+-]?0+$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4044
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4045
  my($tmp,$sign1,$sign2,$len)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4046
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4047
  # Calculate the length of the day in minutes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4048
  $len=24*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4049
  $len=$Curr{"WDlen"}  if ($mode==2 || $mode==3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4050
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4051
  # We have to get the sign of every component explicitely so that a "-0"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4052
  # or "+0" doesn't get lost by treating it numerically (i.e. "-0:0:2" must
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4053
  # be a negative delta).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4054
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4055
  my($y,$mon,$w,$d,$h,$m,$s)=&Delta_Split($delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4056
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4057
  # We need to make sure that the signs of all parts of a delta are the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4058
  # same.  The easiest way to do this is to convert all of the large
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4059
  # components to the smallest ones, then convert the smaller components
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4060
  # back to the larger ones.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4061
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4062
  # Do the year/month part
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4063
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4064
  $mon += $y*12;                         # convert y to m
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4065
  $sign1="+";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4066
  if ($mon<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4067
    $mon *= -1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4068
    $sign1="-";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4069
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4070
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4071
  $y    = $mon/12;                       # convert m to y
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4072
  $mon -= $y*12;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4073
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4074
  $y=0    if ($y eq "-0");               # get around silly -0 problem
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4075
  $mon=0  if ($mon eq "-0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4076
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4077
  # Do the wk/day/hour/min/sec part
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4078
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4079
  {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4080
    # Unfortunately, $s is overflowing for dates more than ~70 years
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4081
    # apart.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4082
    no integer;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4083
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4084
    if ($mode==3 || $mode==2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4085
      $s += $d*$len*60 + $h*3600 + $m*60;        # convert d/h/m to s
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4086
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4087
      $s += ($d+7*$w)*$len*60 + $h*3600 + $m*60; # convert w/d/h/m to s
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4088
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4089
    $sign2="+";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4090
    if ($s<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4091
      $s*=-1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4092
      $sign2="-";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4093
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4094
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4095
    $m  = int($s/60);                    # convert s to m
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4096
    $s -= $m*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4097
    $d  = int($m/$len);                  # convert m to d
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4098
    $m -= $d*$len;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4099
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4100
    # The rest should be fine.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4101
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4102
  $h  = $m/60;                           # convert m to h
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4103
  $m -= $h*60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4104
  if ($mode == 3 || $mode == 2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4105
    $w  = $w*1;                          # get around +0 problem
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4106
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4107
    $w  = $d/7;                          # convert d to w
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4108
    $d -= $w*7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4109
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4110
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4111
  $w=0    if ($w eq "-0");               # get around silly -0 problem
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4112
  $d=0    if ($d eq "-0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4113
  $h=0    if ($h eq "-0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4114
  $m=0    if ($m eq "-0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4115
  $s=0    if ($s eq "-0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4116
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4117
  # Only include two signs if necessary
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4118
  $sign1=$sign2  if ($y==0 and $mon==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4119
  $sign2=$sign1  if ($w==0 and $d==0 and $h==0 and $m==0 and $s==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4120
  $sign2=""  if ($sign1 eq $sign2  and  ! $Cnf{"DeltaSigns"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4121
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4122
  if ($Cnf{"DeltaSigns"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4123
    return "$sign1$y:$sign1$mon:$sign2$w:$sign2$d:$sign2$h:$sign2$m:$sign2$s";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4124
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4125
    return "$sign1$y:$mon:$sign2$w:$d:$h:$m:$s";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4126
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4127
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4128
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4129
# This checks a delta to make sure it is valid.  If it is, it splits
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4130
# it and returns the elements with a sign on each.  The 2nd argument
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4131
# specifies the default sign.  Blank elements are set to 0.  If the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4132
# third element is non-nil, exactly 7 elements must be included.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4133
sub Delta_Split {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4134
  print "DEBUG: Delta_Split\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4135
  my($delta,$sign,$exact)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4136
  my(@delta)=split(/:/,$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4137
  return ()  if ($exact  and $#delta != 6);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4138
  my($i)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4139
  $sign="+"  if (! defined $sign);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4140
  for ($i=0; $i<=$#delta; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4141
    $delta[$i]="0"  if (! $delta[$i]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4142
    return ()  if ($delta[$i] !~ /^[+-]?\d+$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4143
    $sign = ($delta[$i] =~ s/^([+-])// ? $1 : $sign);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4144
    $delta[$i] = $sign.$delta[$i];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4145
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4146
  @delta;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4147
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4148
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4149
# Reads up to 3 arguments.  $h may contain the time in any international
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4150
# format.  Any empty elements are set to 0.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4151
sub Date_ParseTime {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4152
  print "DEBUG: Date_ParseTime\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4153
  my($h,$m,$s)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4154
  my($t)=&CheckTime("one");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4155
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4156
  if (defined $h  and  $h =~ /$t/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4157
    $h=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4158
    $m=$2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4159
    $s=$3   if (defined $3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4160
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4161
  $h="00"  if (! defined $h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4162
  $m="00"  if (! defined $m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4163
  $s="00"  if (! defined $s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4164
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4165
  ($h,$m,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4166
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4167
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4168
# Forms a date with the 6 elements passed in (all of which must be defined).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4169
# No check as to validity is made.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4170
sub Date_Join {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4171
  print "DEBUG: Date_Join\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4172
  foreach (0 .. $#_) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4173
      croak "undefined arg $_ to Date_Join()" if not defined $_[$_];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4174
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4175
  my($y,$m,$d,$h,$mn,$s)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4176
  my($ym,$md,$dh,$hmn,$mns)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4177
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4178
  if      ($Cnf{"Internal"} == 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4179
    $ym=$md=$dh="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4180
    $hmn=$mns=":";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4181
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4182
  } elsif ($Cnf{"Internal"} == 1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4183
    $ym=$md=$dh=$hmn=$mns="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4184
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4185
  } elsif ($Cnf{"Internal"} == 2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4186
    $ym=$md="-";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4187
    $dh=" ";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4188
    $hmn=$mns=":";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4189
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4190
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4191
    confess "ERROR: Invalid internal format in Date_Join.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4192
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4193
  $m="0$m"    if (length($m)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4194
  $d="0$d"    if (length($d)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4195
  $h="0$h"    if (length($h)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4196
  $mn="0$mn"  if (length($mn)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4197
  $s="0$s"    if (length($s)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4198
  "$y$ym$m$md$d$dh$h$hmn$mn$mns$s";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4199
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4200
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4201
# This checks a time.  If it is valid, it splits it and returns 3 elements.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4202
# If "one" or "two" is passed in, a regexp with 1/2 or 2 digit hours is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4203
# returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4204
sub CheckTime {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4205
  print "DEBUG: CheckTime\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4206
  my($time)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4207
  my($h)='(?:0?[0-9]|1[0-9]|2[0-3])';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4208
  my($h2)='(?:0[0-9]|1[0-9]|2[0-3])';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4209
  my($m)='[0-5][0-9]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4210
  my($s)=$m;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4211
  my($hm)="(?:". $Lang{$Cnf{"Language"}}{"SepHM"} ."|:)";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4212
  my($ms)="(?:". $Lang{$Cnf{"Language"}}{"SepMS"} ."|:)";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4213
  my($ss)=$Lang{$Cnf{"Language"}}{"SepSS"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4214
  my($t)="^($h)$hm($m)(?:$ms($s)(?:$ss\\d+)?)?\$";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4215
  if ($time eq "one") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4216
    return $t;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4217
  } elsif ($time eq "two") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4218
    $t="^($h2)$hm($m)(?:$ms($s)(?:$ss\\d+)?)?\$";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4219
    return $t;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4220
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4221
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4222
  if ($time =~ /$t/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4223
    ($h,$m,$s)=($1,$2,$3);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4224
    $h="0$h" if (length($h)<2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4225
    $m="0$m" if (length($m)<2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4226
    $s="00"  if (! defined $s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4227
    return ($h,$m,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4228
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4229
    return ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4230
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4231
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4232
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4233
# This checks a recurrence.  If it is valid, it splits it and returns the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4234
# elements.  Otherwise, it returns an empty list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4235
#    ($recur0,$recur1,$flags,$dateb,$date0,$date1)=&Recur_Split($recur);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4236
sub Recur_Split {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4237
  print "DEBUG: Recur_Split\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4238
  my($recur)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4239
  my(@ret,@tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4240
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4241
  my($R)  = '(\*?(?:[-,0-9]+[:\*]){6}[-,0-9]+)';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4242
  my($F)  = '(?:\*([^*]*))';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4243
  my($DB,$D0,$D1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4244
  $DB=$D0=$D1=$F;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4245
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4246
  if ($recur =~ /^$R$F?$DB?$D0?$D1?$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4247
    @ret=($1,$2,$3,$4,$5);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4248
    @tmp=split(/\*/,shift(@ret));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4249
    return ()  if ($#tmp>1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4250
    return (@tmp,"",@ret)  if ($#tmp==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4251
    return (@tmp,@ret);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4252
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4253
  return ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4254
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4255
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4256
# This checks a date.  If it is valid, it splits it and returns the elements.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4257
# If no date is passed in, it returns a regular expression for the date.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4258
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4259
# The optional second argument says 'I really expect this to be a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4260
# valid Date::Manip object, please throw an exception if it is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4261
# not'.  Otherwise, errors are signalled by returning ().
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4262
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4263
sub Date_Split {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4264
  print "DEBUG: Date_Split\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4265
  my($date, $definitely_valid)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4266
  $definitely_valid = 0 if not defined $definitely_valid;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4267
  my($ym,$md,$dh,$hmn,$mns)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4268
  my($y)='(\d{4})';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4269
  my($m)='(0[1-9]|1[0-2])';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4270
  my($d)='(0[1-9]|[1-2][0-9]|3[0-1])';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4271
  my($h)='([0-1][0-9]|2[0-3])';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4272
  my($mn)='([0-5][0-9])';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4273
  my($s)=$mn;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4274
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4275
  if      ($Cnf{"Internal"} == 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4276
    $ym=$md=$dh="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4277
    $hmn=$mns=":";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4278
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4279
  } elsif ($Cnf{"Internal"} == 1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4280
    $ym=$md=$dh=$hmn=$mns="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4281
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4282
  } elsif ($Cnf{"Internal"} == 2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4283
    $ym=$md="-";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4284
    $dh=" ";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4285
    $hmn=$mns=":";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4286
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4287
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4288
    confess "ERROR: Invalid internal format in Date_Split.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4289
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4290
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4291
  my($t)="^$y$ym$m$md$d$dh$h$hmn$mn$mns$s\$";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4292
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4293
  if (not defined $date or $date eq '') {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4294
      if ($definitely_valid) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4295
	  die "bad date '$date'";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4296
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4297
	  return $t;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4298
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4299
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4300
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4301
  if ($date =~ /$t/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4302
    ($y,$m,$d,$h,$mn,$s)=($1,$2,$3,$4,$5,$6);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4303
    my(@d_in_m)=(0,31,28,31,30,31,30,31,31,30,31,30,31);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4304
    $d_in_m[2]=29  if (&Date_LeapYear($y));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4305
    if ($d>$d_in_m[$m]) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4306
	my $msg = "invalid date $date: day $d of month $m, but only $d_in_m[$m] days in that month";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4307
	if ($definitely_valid) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4308
	    die $msg;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4309
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4310
	else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4311
	    warn $msg;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4312
	    return ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4313
	}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4314
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4315
    return ($y,$m,$d,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4316
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4317
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4318
  if ($definitely_valid) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4319
      die "invalid date $date: doesn't match regexp $t";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4320
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4321
  return ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4322
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4323
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4324
# This returns the date easter occurs on for a given year as ($month,$day).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4325
# This is from the Calendar FAQ.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4326
sub Date_Easter {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4327
  my($y)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4328
  $y=&Date_FixYear($y)  if (length($y)==2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4329
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4330
  my($c) = $y/100;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4331
  my($g) = $y % 19;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4332
  my($k) = ($c-17)/25;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4333
  my($i) = ($c - $c/4 - ($c-$k)/3 + 19*$g + 15) % 30;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4334
  $i     = $i - ($i/28)*(1 - ($i/28)*(29/($i+1))*((21-$g)/11));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4335
  my($j) = ($y + $y/4 + $i + 2 - $c + $c/4) % 7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4336
  my($l) = $i-$j;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4337
  my($m) = 3 + ($l+40)/44;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4338
  my($d) = $l + 28 - 31*($m/4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4339
  return ($m,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4340
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4341
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4342
# This takes a list of years, months, WeekOfMonth's, and optionally
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4343
# DayOfWeek's, and returns a list of dates.  Optionally, a list of dates
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4344
# can be passed in as the 1st argument (with the 2nd argument the null list)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4345
# and the year/month of these will be used.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4346
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4347
# If $FDn is non-zero, the first week of the month contains the first
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4348
# occurence of this day (1=Monday).  If $FIn is non-zero, the first week of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4349
# the month contains the date (i.e. $FIn'th day of the month).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4350
sub Date_Recur_WoM {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4351
  my($y,$m,$w,$d,$FDn,$FIn)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4352
  my(@y)=@$y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4353
  my(@m)=@$m;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4354
  my(@w)=@$w;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4355
  my(@d)=@$d;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4356
  my($date0,$date1,@tmp,@date,$d0,$d1,@tmp2)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4357
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4358
  if (@m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4359
    @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4360
    foreach $y (@y) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4361
      return ()  if (length($y)==1 || length($y)==3 || ! &IsInt($y,0,9999));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4362
      $y=&Date_FixYear($y)  if (length($y)==2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4363
      push(@tmp,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4364
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4365
    @y=sort { $a<=>$b } (@tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4366
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4367
    return ()  if (! @m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4368
    foreach $m (@m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4369
      return ()  if (! &IsInt($m,1,12));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4370
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4371
    @m=sort { $a<=>$b } (@m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4372
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4373
    @tmp=@tmp2=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4374
    foreach $y (@y) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4375
      foreach $m (@m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4376
        push(@tmp,$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4377
        push(@tmp2,$m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4378
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4379
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4380
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4381
    @y=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4382
    @m=@tmp2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4383
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4384
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4385
    foreach $d0 (@y) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4386
      @tmp=&Date_Split($d0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4387
      return ()  if (! @tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4388
      push(@tmp2,$tmp[0]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4389
      push(@m,$tmp[1]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4390
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4391
    @y=@tmp2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4392
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4393
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4394
  return ()  if (! @w);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4395
  foreach $w (@w) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4396
    return ()  if ($w==0  ||  ! &IsInt($w,-5,5));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4397
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4398
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4399
  if (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4400
    foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4401
      return ()  if (! &IsInt($d,1,7));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4402
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4403
    @d=sort { $a<=>$b } (@d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4404
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4405
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4406
  @date=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4407
  foreach $y (@y) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4408
    $m=shift(@m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4409
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4410
    # Find 1st day of this month and next month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4411
    $date0=&Date_Join($y,$m,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4412
    $date1=&DateCalc($date0,"+0:1:0:0:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4413
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4414
    if (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4415
      foreach $d (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4416
        # Find 1st occurence of DOW (in both months)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4417
        $d0=&Date_GetNext($date0,$d,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4418
        $d1=&Date_GetNext($date1,$d,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4419
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4420
        @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4421
        while (&Date_Cmp($d0,$d1)<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4422
          push(@tmp,$d0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4423
          $d0=&DateCalc($d0,"+0:0:1:0:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4424
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4425
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4426
        @tmp2=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4427
        foreach $w (@w) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4428
          if ($w>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4429
            push(@tmp2,$tmp[$w-1]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4430
          } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4431
            push(@tmp2,$tmp[$#tmp+1+$w]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4432
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4433
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4434
        @tmp2=sort(@tmp2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4435
        push(@date,@tmp2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4436
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4437
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4438
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4439
      # Find 1st day of 1st week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4440
      if ($FDn != 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4441
        $date0=&Date_GetNext($date0,$FDn,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4442
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4443
        $date0=&Date_Join($y,$m,$FIn,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4444
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4445
      $date0=&Date_GetPrev($date0,$Cnf{"FirstDay"},1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4446
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4447
      # Find 1st day of 1st week of next month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4448
      if ($FDn != 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4449
        $date1=&Date_GetNext($date1,$FDn,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4450
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4451
        $date1=&DateCalc($date1,"+0:0:0:".($FIn-1).":0:0:0")  if ($FIn>1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4452
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4453
      $date1=&Date_GetPrev($date1,$Cnf{"FirstDay"},1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4454
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4455
      @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4456
      while (&Date_Cmp($date0,$date1)<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4457
        push(@tmp,$date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4458
        $date0=&DateCalc($date0,"+0:0:1:0:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4459
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4460
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4461
      @tmp2=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4462
      foreach $w (@w) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4463
        if ($w>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4464
          push(@tmp2,$tmp[$w-1]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4465
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4466
          push(@tmp2,$tmp[$#tmp+1+$w]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4467
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4468
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4469
      @tmp2=sort(@tmp2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4470
      push(@date,@tmp2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4471
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4472
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4473
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4474
  @date;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4475
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4476
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4477
# This returns a sorted list of dates formed by adding/subtracting
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4478
# $delta to $dateb in the range $date0<=$d<$dateb.  The first date int
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4479
# the list is actually the first date<$date0 and the last date in the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4480
# list is the first date>=$date1 (because sometimes the set part will
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4481
# move the date back into the range).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4482
sub Date_Recur {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4483
  my($date0,$date1,$dateb,$delta)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4484
  my(@ret,$d)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4485
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4486
  while (&Date_Cmp($dateb,$date0)<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4487
    $dateb=&DateCalc_DateDelta($dateb,$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4488
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4489
  while (&Date_Cmp($dateb,$date1)>=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4490
    $dateb=&DateCalc_DateDelta($dateb,"-$delta");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4491
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4492
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4493
  # Add the dates $date0..$dateb
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4494
  $d=$dateb;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4495
  while (&Date_Cmp($d,$date0)>=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4496
    unshift(@ret,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4497
    $d=&DateCalc_DateDelta($d,"-$delta");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4498
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4499
  # Add the first date earler than the range
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4500
  unshift(@ret,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4501
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4502
  # Add the dates $dateb..$date1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4503
  $d=&DateCalc_DateDelta($dateb,$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4504
  while (&Date_Cmp($d,$date1)<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4505
    push(@ret,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4506
    $d=&DateCalc_DateDelta($d,$delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4507
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4508
  # Add the first date later than the range
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4509
  push(@ret,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4510
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4511
  @ret;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4512
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4513
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4514
# This sets the values in each date of a recurrence.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4515
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4516
# $h,$m,$s can each be values or lists "1-2,4".  If any are equal to "-1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4517
# they are not set (and none of the larger elements are set).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4518
sub Date_RecurSetTime {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4519
  my($date0,$date1,$dates,$h,$m,$s)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4520
  my(@dates)=@$dates;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4521
  my(@h,@m,@s,$date,@tmp)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4522
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4523
  $m="-1"  if ($s eq "-1");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4524
  $h="-1"  if ($m eq "-1");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4525
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4526
  if ($h ne "-1") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4527
    @h=&ReturnList($h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4528
    return ()  if ! (@h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4529
    @h=sort { $a<=>$b } (@h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4530
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4531
    @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4532
    foreach $date (@dates) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4533
      foreach $h (@h) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4534
        push(@tmp,&Date_SetDateField($date,"h",$h,1));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4535
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4536
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4537
    @dates=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4538
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4539
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4540
  if ($m ne "-1") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4541
    @m=&ReturnList($m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4542
    return ()  if ! (@m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4543
    @m=sort { $a<=>$b } (@m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4544
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4545
    @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4546
    foreach $date (@dates) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4547
      foreach $m (@m) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4548
        push(@tmp,&Date_SetDateField($date,"mn",$m,1));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4549
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4550
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4551
    @dates=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4552
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4553
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4554
  if ($s ne "-1") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4555
    @s=&ReturnList($s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4556
    return ()  if ! (@s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4557
    @s=sort { $a<=>$b } (@s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4558
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4559
    @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4560
    foreach $date (@dates) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4561
      foreach $s (@s) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4562
        push(@tmp,&Date_SetDateField($date,"s",$s,1));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4563
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4564
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4565
    @dates=@tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4566
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4567
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4568
  @tmp=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4569
  foreach $date (@dates) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4570
    push(@tmp,$date)  if (&Date_Cmp($date,$date0)>=0  &&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4571
                          &Date_Cmp($date,$date1)<0  &&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4572
                          &Date_Split($date));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4573
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4574
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4575
  @tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4576
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4577
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4578
sub DateCalc_DateDate {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4579
  print "DEBUG: DateCalc_DateDate\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4580
  my($D1,$D2,$mode)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4581
  my(@d_in_m)=(0,31,28,31,30,31,30,31,31,30,31,30,31);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4582
  $mode=0  if (! defined $mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4583
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4584
  # Exact mode
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4585
  if ($mode==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4586
    my($y1,$m1,$d1,$h1,$mn1,$s1)=&Date_Split($D1, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4587
    my($y2,$m2,$d2,$h2,$mn2,$s2)=&Date_Split($D2, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4588
    my($i,@delta,$d,$delta,$y)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4589
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4590
    # form the delta for hour/min/sec
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4591
    $delta[4]=$h2-$h1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4592
    $delta[5]=$mn2-$mn1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4593
    $delta[6]=$s2-$s1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4594
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4595
    # form the delta for yr/mon/day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4596
    $delta[0]=$delta[1]=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4597
    $d=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4598
    if ($y2>$y1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4599
      $d=&Date_DaysInYear($y1) - &Date_DayOfYear($m1,$d1,$y1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4600
      $d+=&Date_DayOfYear($m2,$d2,$y2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4601
      for ($y=$y1+1; $y<$y2; $y++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4602
        $d+= &Date_DaysInYear($y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4603
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4604
    } elsif ($y2<$y1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4605
      $d=&Date_DaysInYear($y2) - &Date_DayOfYear($m2,$d2,$y2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4606
      $d+=&Date_DayOfYear($m1,$d1,$y1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4607
      for ($y=$y2+1; $y<$y1; $y++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4608
        $d+= &Date_DaysInYear($y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4609
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4610
      $d *= -1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4611
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4612
      $d=&Date_DayOfYear($m2,$d2,$y2) - &Date_DayOfYear($m1,$d1,$y1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4613
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4614
    $delta[2]=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4615
    $delta[3]=$d;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4616
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4617
    for ($i=0; $i<7; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4618
      $delta[$i]="+".$delta[$i]  if ($delta[$i]>=0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4619
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4620
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4621
    $delta=join(":",@delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4622
    $delta=&Delta_Normalize($delta,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4623
    return $delta;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4624
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4625
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4626
  my($date1,$date2)=($D1,$D2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4627
  my($tmp,$sign,$err,@tmp)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4628
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4629
  # make sure both are work days
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4630
  if ($mode==2 || $mode==3) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4631
    $date1=&Date_NextWorkDay($date1,0,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4632
    $date2=&Date_NextWorkDay($date2,0,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4633
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4634
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4635
  # make sure date1 comes before date2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4636
  if (&Date_Cmp($date1,$date2)>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4637
    $sign="-";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4638
    $tmp=$date1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4639
    $date1=$date2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4640
    $date2=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4641
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4642
    $sign="+";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4643
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4644
  if (&Date_Cmp($date1,$date2)==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4645
    return "+0:+0:+0:+0:+0:+0:+0"  if ($Cnf{"DeltaSigns"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4646
    return "+0:0:0:0:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4647
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4648
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4649
  my($y1,$m1,$d1,$h1,$mn1,$s1)=&Date_Split($date1, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4650
  my($y2,$m2,$d2,$h2,$mn2,$s2)=&Date_Split($date2, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4651
  my($dy,$dm,$dw,$dd,$dh,$dmn,$ds,$ddd)=(0,0,0,0,0,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4652
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4653
  if ($mode != 3) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4654
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4655
    # Do years
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4656
    $dy=$y2-$y1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4657
    $dm=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4658
    if ($dy>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4659
      $tmp=&DateCalc_DateDelta($date1,"+$dy:0:0:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4660
      if (&Date_Cmp($tmp,$date2)>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4661
        $dy--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4662
        $tmp=$date1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4663
        $tmp=&DateCalc_DateDelta($date1,"+$dy:0:0:0:0:0:0",\$err,0)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4664
          if ($dy>0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4665
        $dm=12;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4666
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4667
      $date1=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4668
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4669
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4670
    # Do months
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4671
    $dm+=$m2-$m1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4672
    if ($dm>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4673
      $tmp=&DateCalc_DateDelta($date1,"+0:$dm:0:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4674
      if (&Date_Cmp($tmp,$date2)>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4675
        $dm--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4676
        $tmp=$date1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4677
        $tmp=&DateCalc_DateDelta($date1,"+0:$dm:0:0:0:0:0",\$err,0)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4678
          if ($dm>0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4679
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4680
      $date1=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4681
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4682
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4683
    # At this point, check to see that we're on a business day again so that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4684
    # Aug 3 (Monday) -> Sep 3 (Sunday) -> Sep 4 (Monday)  = 1 month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4685
    if ($mode==2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4686
      if (! &Date_IsWorkDay($date1,0)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4687
        $date1=&Date_NextWorkDay($date1,0,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4688
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4689
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4690
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4691
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4692
  # Do days
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4693
  if ($mode==2 || $mode==3) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4694
    $dd=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4695
    while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4696
      $tmp=&Date_NextWorkDay($date1,1,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4697
      if (&Date_Cmp($tmp,$date2)<=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4698
        $dd++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4699
        $date1=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4700
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4701
        last;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4702
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4703
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4704
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4705
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4706
    ($y1,$m1,$d1)=( &Date_Split($date1, 1) )[0..2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4707
    $dd=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4708
    # If we're jumping across months, set $d1 to the first of the next month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4709
    # (or possibly the 0th of next month which is equivalent to the last day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4710
    # of this month)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4711
    if ($m1!=$m2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4712
      $d_in_m[2]=29  if (&Date_LeapYear($y1));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4713
      $dd=$d_in_m[$m1]-$d1+1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4714
      $d1=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4715
      $tmp=&DateCalc_DateDelta($date1,"+0:0:0:$dd:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4716
      if (&Date_Cmp($tmp,$date2)>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4717
        $dd--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4718
        $d1--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4719
        $tmp=&DateCalc_DateDelta($date1,"+0:0:0:$dd:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4720
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4721
      $date1=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4722
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4723
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4724
    $ddd=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4725
    if ($d1<$d2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4726
      $ddd=$d2-$d1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4727
      $tmp=&DateCalc_DateDelta($date1,"+0:0:0:$ddd:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4728
      if (&Date_Cmp($tmp,$date2)>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4729
        $ddd--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4730
        $tmp=&DateCalc_DateDelta($date1,"+0:0:0:$ddd:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4731
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4732
      $date1=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4733
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4734
    $dd+=$ddd;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4735
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4736
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4737
  # in business mode, make sure h1 comes before h2 (if not find delta between
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4738
  # now and end of day and move to start of next business day)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4739
  $d1=( &Date_Split($date1, 1) )[2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4740
  $dh=$dmn=$ds=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4741
  if ($mode==2 || $mode==3  and  $d1 != $d2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4742
    $tmp=&Date_SetTime($date1,$Cnf{"WorkDayEnd"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4743
    $tmp=&DateCalc_DateDelta($tmp,"+0:0:0:0:0:1:0")
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4744
      if ($Cnf{"WorkDay24Hr"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4745
    $tmp=&DateCalc_DateDate($date1,$tmp,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4746
    ($tmp,$tmp,$tmp,$tmp,$dh,$dmn,$ds)=&Delta_Split($tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4747
    $date1=&Date_NextWorkDay($date1,1,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4748
    $date1=&Date_SetTime($date1,$Cnf{"WorkDayBeg"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4749
    $d1=( &Date_Split($date1, 1) )[2];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4750
    confess "ERROR: DateCalc DateDate Business.\n"  if ($d1 != $d2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4751
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4752
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4753
  # Hours, minutes, seconds
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4754
  $tmp=&DateCalc_DateDate($date1,$date2,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4755
  @tmp=&Delta_Split($tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4756
  $dh  += $tmp[4];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4757
  $dmn += $tmp[5];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4758
  $ds  += $tmp[6];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4759
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4760
  $tmp="$sign$dy:$dm:0:$dd:$dh:$dmn:$ds";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4761
  &Delta_Normalize($tmp,$mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4762
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4763
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4764
sub DateCalc_DeltaDelta {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4765
  print "DEBUG: DateCalc_DeltaDelta\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4766
  my($D1,$D2,$mode)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4767
  my(@delta1,@delta2,$i,$delta,@delta)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4768
  $mode=0  if (! defined $mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4769
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4770
  @delta1=&Delta_Split($D1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4771
  @delta2=&Delta_Split($D2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4772
  for ($i=0; $i<7; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4773
    $delta[$i]=$delta1[$i]+$delta2[$i];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4774
    $delta[$i]="+".$delta[$i]  if ($delta[$i]>=0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4775
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4776
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4777
  $delta=join(":",@delta);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4778
  $delta=&Delta_Normalize($delta,$mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4779
  return $delta;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4780
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4781
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4782
sub DateCalc_DateDelta {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4783
  print "DEBUG: DateCalc_DateDelta\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4784
  my($D1,$D2,$errref,$mode)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4785
  my($date)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4786
  my(@d_in_m)=(0,31,28,31,30,31,30,31,31,30,31,30,31);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4787
  my($h1,$m1,$h2,$m2,$len,$hh,$mm)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4788
  $mode=0  if (! defined $mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4789
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4790
  if ($mode==2 || $mode==3) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4791
    $h1=$Curr{"WDBh"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4792
    $m1=$Curr{"WDBm"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4793
    $h2=$Curr{"WDEh"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4794
    $m2=$Curr{"WDEm"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4795
    $hh=$h2-$h1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4796
    $mm=$m2-$m1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4797
    if ($mm<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4798
      $hh--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4799
      $mm+=60;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4800
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4801
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4802
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4803
  # Date, delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4804
  my($y,$m,$d,$h,$mn,$s)=&Date_Split($D1, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4805
  my($dy,$dm,$dw,$dd,$dh,$dmn,$ds)=&Delta_Split($D2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4806
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4807
  # do the month/year part
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4808
  $y+=$dy;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4809
  while (length($y)<4) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4810
    $y = "0$y";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4811
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4812
  &ModuloAddition(-12,$dm,\$m,\$y);   # -12 means 1-12 instead of 0-11
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4813
  $d_in_m[2]=29  if (&Date_LeapYear($y));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4814
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4815
  # if we have gone past the last day of a month, move the date back to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4816
  # the last day of the month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4817
  if ($d>$d_in_m[$m]) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4818
    $d=$d_in_m[$m];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4819
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4820
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4821
  # do the week part
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4822
  if ($mode==0  ||  $mode==1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4823
    $dd += $dw*7;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4824
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4825
    $date=&DateCalc_DateDelta(&Date_Join($y,$m,$d,$h,$mn,$s),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4826
                              "+0:0:$dw:0:0:0:0",0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4827
    ($y,$m,$d,$h,$mn,$s)=&Date_Split($date, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4828
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4829
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4830
  # in business mode, set the day to a work day at this point so the h/mn/s
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4831
  # stuff will work out
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4832
  if ($mode==2 || $mode==3) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4833
    $d=$d_in_m[$m] if ($d>$d_in_m[$m]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4834
    $date=&Date_NextWorkDay(&Date_Join($y,$m,$d,$h,$mn,$s),0,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4835
    ($y,$m,$d,$h,$mn,$s)=&Date_Split($date, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4836
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4837
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4838
  # seconds, minutes, hours
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4839
  &ModuloAddition(60,$ds,\$s,\$mn);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4840
  if ($mode==2 || $mode==3) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4841
    while (1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4842
      &ModuloAddition(60,$dmn,\$mn,\$h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4843
      $h+= $dh;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4844
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4845
      if ($h>$h2  or  $h==$h2 && $mn>$m2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4846
        $dh=$h-$h2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4847
        $dmn=$mn-$m2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4848
        $h=$h1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4849
        $mn=$m1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4850
        $dd++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4851
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4852
      } elsif ($h<$h1  or  $h==$h1 && $mn<$m1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4853
        $dh=$h-$h1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4854
        $dmn=$m1-$mn;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4855
        $h=$h2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4856
        $mn=$m2;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4857
        $dd--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4858
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4859
      } elsif ($h==$h2  &&  $mn==$m2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4860
        $dd++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4861
        $dh=-$hh;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4862
        $dmn=-$mm;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4863
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4864
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4865
        last;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4866
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4867
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4868
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4869
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4870
    &ModuloAddition(60,$dmn,\$mn,\$h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4871
    &ModuloAddition(24,$dh,\$h,\$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4872
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4873
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4874
  # If we have just gone past the last day of the month, we need to make
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4875
  # up for this:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4876
  if ($d>$d_in_m[$m]) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4877
    $dd+= $d-$d_in_m[$m];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4878
    $d=$d_in_m[$m];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4879
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4880
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4881
  # days
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4882
  if ($mode==2 || $mode==3) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4883
    if ($dd>=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4884
      $date=&Date_NextWorkDay(&Date_Join($y,$m,$d,$h,$mn,$s),$dd,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4885
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4886
      $date=&Date_PrevWorkDay(&Date_Join($y,$m,$d,$h,$mn,$s),-$dd,1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4887
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4888
    ($y,$m,$d,$h,$mn,$s)=&Date_Split($date, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4889
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4890
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4891
    $d_in_m[2]=29  if (&Date_LeapYear($y));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4892
    $d=$d_in_m[$m]  if ($d>$d_in_m[$m]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4893
    $d += $dd;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4894
    while ($d<1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4895
      $m--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4896
      if ($m==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4897
        $m=12;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4898
        $y--;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4899
        if (&Date_LeapYear($y)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4900
          $d_in_m[2]=29;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4901
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4902
          $d_in_m[2]=28;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4903
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4904
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4905
      $d += $d_in_m[$m];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4906
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4907
    while ($d>$d_in_m[$m]) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4908
      $d -= $d_in_m[$m];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4909
      $m++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4910
      if ($m==13) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4911
        $m=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4912
        $y++;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4913
        if (&Date_LeapYear($y)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4914
          $d_in_m[2]=29;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4915
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4916
          $d_in_m[2]=28;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4917
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4918
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4919
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4920
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4921
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4922
  if ($y<0 or $y>9999) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4923
    $$errref=3;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4924
    return;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4925
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4926
  &Date_Join($y,$m,$d,$h,$mn,$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4927
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4928
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4929
sub Date_UpdateHolidays {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4930
  print "DEBUG: Date_UpdateHolidays\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4931
  my($year)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4932
  $Holiday{"year"}=$year;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4933
  $Holiday{"dates"}{$year}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4934
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4935
  my($date,$delta,$err)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4936
  my($key,@tmp,$tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4937
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4938
  foreach $key (keys %{ $Holiday{"desc"} }) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4939
    @tmp=&Recur_Split($key);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4940
    if (@tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4941
      $tmp=&ParseDateString("${year}010100:00:00");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4942
      ($date)=&ParseRecur($key,$tmp,$tmp,($year+1)."-01-01");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4943
      next  if (! $date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4944
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4945
    } elsif ($key =~ /^(.*)([+-].*)$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4946
      # Date +/- Delta
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4947
      ($date,$delta)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4948
      $tmp=&ParseDateString("$date $year");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4949
      if ($tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4950
        $date=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4951
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4952
        $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4953
        next  if ($date !~ /^$year/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4954
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4955
      $date=&DateCalc($date,$delta,\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4956
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4957
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4958
      # Date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4959
      $date=$key;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4960
      $tmp=&ParseDateString("$date $year");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4961
      if ($tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4962
        $date=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4963
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4964
        $date=&ParseDateString($date);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4965
        next  if ($date !~ /^$year/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4966
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4967
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4968
    $Holiday{"dates"}{$year}{$date}=$Holiday{"desc"}{$key};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4969
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4970
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4971
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4972
# This sets a Date::Manip config variable.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4973
sub Date_SetConfigVariable {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4974
  print "DEBUG: Date_SetConfigVariable\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4975
  my($var,$val)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4976
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4977
  # These are most appropriate for command line options instead of in files.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4978
  $Cnf{"PathSep"}=$val,          return  if ($var =~ /^PathSep$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4979
  $Cnf{"PersonalCnf"}=$val,      return  if ($var =~ /^PersonalCnf$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4980
  $Cnf{"PersonalCnfPath"}=$val,  return  if ($var =~ /^PersonalCnfPath$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4981
  &EraseHolidays(),              return  if ($var =~ /^EraseHolidays$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4982
  $Cnf{"IgnoreGlobalCnf"}=1,     return  if ($var =~ /^IgnoreGlobalCnf$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4983
  $Cnf{"GlobalCnf"}=$val,        return  if ($var =~ /^GlobalCnf$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4984
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4985
  $Curr{"InitLang"}=1,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4986
  $Cnf{"Language"}=$val,         return  if ($var =~ /^Language$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4987
  $Cnf{"DateFormat"}=$val,       return  if ($var =~ /^DateFormat$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4988
  $Cnf{"TZ"}=$val,               return  if ($var =~ /^TZ$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4989
  $Cnf{"ConvTZ"}=$val,           return  if ($var =~ /^ConvTZ$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4990
  $Cnf{"Internal"}=$val,         return  if ($var =~ /^Internal$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4991
  $Cnf{"FirstDay"}=$val,         return  if ($var =~ /^FirstDay$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4992
  $Cnf{"WorkWeekBeg"}=$val,      return  if ($var =~ /^WorkWeekBeg$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4993
  $Cnf{"WorkWeekEnd"}=$val,      return  if ($var =~ /^WorkWeekEnd$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4994
  $Cnf{"WorkDayBeg"}=$val,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4995
  $Curr{"ResetWorkDay"}=1,       return  if ($var =~ /^WorkDayBeg$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4996
  $Cnf{"WorkDayEnd"}=$val,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4997
  $Curr{"ResetWorkDay"}=1,       return  if ($var =~ /^WorkDayEnd$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4998
  $Cnf{"WorkDay24Hr"}=$val,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  4999
  $Curr{"ResetWorkDay"}=1,       return  if ($var =~ /^WorkDay24Hr$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5000
  $Cnf{"DeltaSigns"}=$val,       return  if ($var =~ /^DeltaSigns$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5001
  $Cnf{"Jan1Week1"}=$val,        return  if ($var =~ /^Jan1Week1$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5002
  $Cnf{"YYtoYYYY"}=$val,         return  if ($var =~ /^YYtoYYYY$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5003
  $Cnf{"UpdateCurrTZ"}=$val,     return  if ($var =~ /^UpdateCurrTZ$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5004
  $Cnf{"IntCharSet"}=$val,       return  if ($var =~ /^IntCharSet$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5005
  $Curr{"DebugVal"}=$val,        return  if ($var =~ /^Debug$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5006
  $Cnf{"TomorrowFirst"}=$val,    return  if ($var =~ /^TomorrowFirst$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5007
  $Cnf{"ForceDate"}=$val,        return  if ($var =~ /^ForceDate$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5008
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5009
  confess "ERROR: Unknown configuration variable $var in Date::Manip.\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5010
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5011
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5012
sub EraseHolidays {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5013
  print "DEBUG: EraseHolidays\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5014
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5015
  $Cnf{"EraseHolidays"}=0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5016
  delete $Holiday{"list"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5017
  $Holiday{"list"}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5018
  delete $Holiday{"desc"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5019
  $Holiday{"desc"}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5020
  $Holiday{"dates"}={};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5021
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5022
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5023
# This returns a pointer to a list of times and events in the format
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5024
#    [ date, [ events ], date, [ events ], ... ]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5025
# where each list of events are events that are in effect at the date
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5026
# immediately preceding the list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5027
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5028
# This takes either one date or two dates as arguments.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5029
sub Events_Calc {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5030
  print "DEBUG: Events_Calc\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5031
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5032
  my($date0,$date1)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5033
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5034
  my($tmp);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5035
  $date0=&ParseDateString($date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5036
  return undef  if (! $date0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5037
  if ($date1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5038
    $date1=&ParseDateString($date1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5039
    if (&Date_Cmp($date0,$date1)>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5040
      $tmp=$date1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5041
      $date1=$date0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5042
      $date0=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5043
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5044
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5045
    $date1=&DateCalc_DateDelta($date0,"+0:0:0:0:0:0:1");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5046
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5047
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5048
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5049
  #   [ d0,d1,del,name ]     => [ d0, d1+del )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5050
  #   [ d0,0,del,name ]      => [ d0, d0+del )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5051
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5052
  my(%ret,$d0,$d1,$del,$name,$c0,$c1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5053
  my(@tmp)=@{ $Events{"dates"} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5054
 DATE: while (@tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5055
    ($d0,$d1,$del,$name)=splice(@tmp,0,4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5056
    $d0=&ParseDateString($d0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5057
    $d1=&ParseDateString($d1)   if ($d1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5058
    $del=&ParseDateDelta($del)  if ($del);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5059
    if ($d1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5060
      if ($del) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5061
        $d1=&DateCalc_DateDelta($d1,$del);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5062
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5063
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5064
      $d1=&DateCalc_DateDelta($d0,$del);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5065
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5066
    if (&Date_Cmp($d0,$d1)>0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5067
      $tmp=$d1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5068
      $d1=$d0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5069
      $d0=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5070
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5071
    #         [ date0,date1 )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5072
    # [ d0,d1 )      OR     [ d0,d1 )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5073
    next DATE  if (&Date_Cmp($d1,$date0)<=0  ||
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5074
                   &Date_Cmp($d0,$date1)>=0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5075
    #      [ date0,date1 )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5076
    # [ d0,d1 )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5077
    # [ d0,                  d1 )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5078
    if (&Date_Cmp($d0,$date0)<=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5079
      push @{ $ret{$date0} },$name;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5080
      push @{ $ret{$d1} },"!$name"  if (&Date_Cmp($d1,$date1)<0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5081
      next DATE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5082
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5083
    #      [ date0,date1 )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5084
    #                 [ d0,d1 )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5085
    if (&Date_Cmp($d1,$date1)>=0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5086
      push @{ $ret{$d0} },$name;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5087
      next DATE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5088
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5089
    #      [ date0,date1 )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5090
    #         [ d0,d1 )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5091
    push @{ $ret{$d0} },$name;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5092
    push @{ $ret{$d1} },"!$name";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5093
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5094
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5095
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5096
  #   [ recur,delta0,delta1,name ]   => [ {date-delta0},{date+delta1} )
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5097
  #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5098
  my($rec,$del0,$del1,@d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5099
  @tmp=@{ $Events{"recur"} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5100
 RECUR: while (@tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5101
    ($rec,$del0,$del1,$name)=splice(@tmp,0,4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5102
    @d=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5103
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5104
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5105
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5106
  # Sort them AND take into account the "!$name" entries.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5107
  my(%tmp,$date,@tmp2,@ret);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5108
  @d=sort { &Date_Cmp($a,$b) } keys %ret;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5109
  foreach $date (@d) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5110
    @tmp=@{ $ret{$date} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5111
    @tmp2=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5112
    foreach $tmp (@tmp) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5113
      push(@tmp2,$tmp), next  if ($tmp =~ /^!/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5114
      $tmp{$tmp}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5115
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5116
    foreach $tmp (@tmp2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5117
      $tmp =~ s/^!//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5118
      delete $tmp{$tmp};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5119
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5120
    push(@ret,$date,[ keys %tmp ]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5121
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5122
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5123
  return \@ret;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5124
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5125
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5126
# This parses the raw events list
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5127
sub Events_ParseRaw {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5128
  print "DEBUG: Events_ParseRaw\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5129
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5130
  # Only need to be parsed once
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5131
  my($force)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5132
  $Events{"parsed"}=0  if ($force);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5133
  return  if ($Events{"parsed"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5134
  $Events{"parsed"}=1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5135
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5136
  my(@events)=@{ $Events{"raw"} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5137
  my($event,$name,@event,$date0,$date1,$tmp,$delta,$recur0,$recur1,@recur,$r,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5138
     $recur);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5139
 EVENT: while (@events) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5140
    ($event,$name)=splice(@events,0,2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5141
    @event=split(/\s*;\s*/,$event);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5142
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5143
    if ($#event == 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5144
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5145
      if ($date0=&ParseDateString($event[0])) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5146
        #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5147
        # date = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5148
        #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5149
        $tmp=&ParseDateString("$event[0] 00:00:00");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5150
        if ($tmp  &&  $tmp eq $date0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5151
          $delta="+0:0:0:1:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5152
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5153
          $delta="+0:0:0:0:1:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5154
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5155
        push @{ $Events{"dates"} },($date0,0,$delta,$name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5156
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5157
      } elsif ($recur=&ParseRecur($event[0])) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5158
        #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5159
        # recur = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5160
        #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5161
        ($recur0,$recur1)=&Recur_Split($recur);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5162
        if ($recur0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5163
          if ($recur1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5164
            $r="$recur0:$recur1";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5165
          } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5166
            $r=$recur0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5167
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5168
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5169
          $r=$recur1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5170
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5171
        (@recur)=split(/:/,$r);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5172
        if (pop(@recur)==0  &&  pop(@recur)==0  &&  pop(@recur)==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5173
          $delta="+0:0:0:1:0:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5174
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5175
          $delta="+0:0:0:0:1:0:0";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5176
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5177
        push @{ $Events{"recur"} },($recur,0,$delta,$name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5178
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5179
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5180
        # ??? = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5181
        warn "WARNING: illegal event ignored [ @event ]\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5182
        next EVENT;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5183
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5184
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5185
    } elsif ($#event == 1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5186
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5187
      if ($date0=&ParseDateString($event[0])) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5188
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5189
        if ($date1=&ParseDateString($event[1])) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5190
          #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5191
          # date ; date = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5192
          #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5193
          $tmp=&ParseDateString("$event[1] 00:00:00");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5194
          if ($tmp  &&  $tmp eq $date1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5195
            $date1=&DateCalc_DateDelta($date1,"+0:0:0:1:0:0:0");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5196
          }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5197
          push @{ $Events{"dates"} },($date0,$date1,0,$name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5198
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5199
        } elsif ($delta=&ParseDateDelta($event[1])) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5200
          #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5201
          # date ; delta = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5202
          #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5203
          push @{ $Events{"dates"} },($date0,0,$delta,$name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5204
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5205
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5206
          # date ; ??? = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5207
          warn "WARNING: illegal event ignored [ @event ]\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5208
          next EVENT;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5209
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5210
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5211
      } elsif ($recur=&ParseRecur($event[0])) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5212
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5213
        if ($delta=&ParseDateDelta($event[1])) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5214
          #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5215
          # recur ; delta = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5216
          #
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5217
          push @{ $Events{"recur"} },($recur,0,$delta,$name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5218
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5219
        } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5220
          # recur ; ??? = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5221
          warn "WARNING: illegal event ignored [ @event ]\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5222
          next EVENT;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5223
        }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5224
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5225
      } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5226
        # ??? ; ??? = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5227
        warn "WARNING: illegal event ignored [ @event ]\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5228
        next EVENT;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5229
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5230
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5231
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5232
      # date ; delta0 ; delta1 = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5233
      # recur ; delta0 ; delta1 = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5234
      # ??? ; ??? ; ??? ... = event
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5235
      warn "WARNING: illegal event ignored [ @event ]\n";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5236
      next EVENT;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5237
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5238
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5239
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5240
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5241
# This reads an init file.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5242
sub Date_InitFile {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5243
  print "DEBUG: Date_InitFile\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5244
  my($file)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5245
  my($in)=new IO::File;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5246
  local($_)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5247
  my($section)="vars";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5248
  my($var,$val,$recur,$name)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5249
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5250
  $in->open($file)  ||  return;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5251
  while(defined ($_=<$in>)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5252
    chomp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5253
    s/^\s+//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5254
    s/\s+$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5255
    next  if (! $_  or  /^\#/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5256
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5257
    if (/^\*holiday/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5258
      $section="holiday";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5259
      &EraseHolidays()  if ($section =~ /holiday/i  &&  $Cnf{"EraseHolidays"});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5260
      next;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5261
    } elsif (/^\*events/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5262
      $section="events";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5263
      next;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5264
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5265
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5266
    if ($section =~ /var/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5267
      confess "ERROR: invalid Date::Manip config file line.\n  $_\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5268
        if (! /(.*\S)\s*=\s*(.*)$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5269
      ($var,$val)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5270
      &Date_SetConfigVariable($var,$val);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5271
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5272
    } elsif ($section =~ /holiday/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5273
      confess "ERROR: invalid Date::Manip config file line.\n  $_\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5274
        if (! /(.*\S)\s*=\s*(.*)$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5275
      ($recur,$name)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5276
      $name=""  if (! defined $name);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5277
      $Holiday{"desc"}{$recur}=$name;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5278
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5279
    } elsif ($section =~ /events/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5280
      confess "ERROR: invalid Date::Manip config file line.\n  $_\n"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5281
        if (! /(.*\S)\s*=\s*(.*)$/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5282
      ($val,$var)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5283
      push @{ $Events{"raw"} },($val,$var);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5284
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5285
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5286
      # A section not currently used by Date::Manip (but may be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5287
      # used by some extension to it).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5288
      next;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5289
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5290
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5291
  close($in);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5292
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5293
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5294
# $flag=&Date_TimeCheck(\$h,\$mn,\$s,\$ampm);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5295
#   Returns 1 if any of the fields are bad.  All fields are optional, and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5296
#   all possible checks are done on the data.  If a field is not passed in,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5297
#   it is set to default values.  If data is missing, appropriate defaults
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5298
#   are supplied.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5299
sub Date_TimeCheck {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5300
  print "DEBUG: Date_TimeCheck\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5301
  my($h,$mn,$s,$ampm)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5302
  my($tmp1,$tmp2,$tmp3)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5303
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5304
  $$h=""     if (! defined $$h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5305
  $$mn=""    if (! defined $$mn);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5306
  $$s=""     if (! defined $$s);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5307
  $$ampm=""  if (! defined $$ampm);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5308
  $$ampm=uc($$ampm)  if ($$ampm);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5309
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5310
  # Check hour
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5311
  $tmp1=$Lang{$Cnf{"Language"}}{"AmPm"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5312
  $tmp2="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5313
  if ($$ampm =~ /^$tmp1$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5314
    $tmp3=$Lang{$Cnf{"Language"}}{"AM"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5315
    $tmp2="AM"  if ($$ampm =~ /^$tmp3$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5316
    $tmp3=$Lang{$Cnf{"Language"}}{"PM"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5317
    $tmp2="PM"  if ($$ampm =~ /^$tmp3$/i);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5318
  } elsif ($$ampm) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5319
    return 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5320
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5321
  if ($tmp2 eq "AM" || $tmp2 eq "PM") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5322
    $$h="0$$h"    if (length($$h)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5323
    return 1      if ($$h<1 || $$h>12);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5324
    $$h="00"      if ($tmp2 eq "AM"  and  $$h==12);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5325
    $$h += 12     if ($tmp2 eq "PM"  and  $$h!=12);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5326
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5327
    $$h="00"      if ($$h eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5328
    $$h="0$$h"    if (length($$h)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5329
    return 1      if (! &IsInt($$h,0,23));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5330
    $tmp2="AM"    if ($$h<12);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5331
    $tmp2="PM"    if ($$h>=12);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5332
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5333
  $$ampm=$Lang{$Cnf{"Language"}}{"AMstr"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5334
  $$ampm=$Lang{$Cnf{"Language"}}{"PMstr"}  if ($tmp2 eq "PM");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5335
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5336
  # Check minutes
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5337
  $$mn="00"       if ($$mn eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5338
  $$mn="0$$mn"    if (length($$mn)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5339
  return 1        if (! &IsInt($$mn,0,59));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5340
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5341
  # Check seconds
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5342
  $$s="00"        if ($$s eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5343
  $$s="0$$s"      if (length($$s)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5344
  return 1        if (! &IsInt($$s,0,59));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5345
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5346
  return 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5347
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5348
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5349
# $flag=&Date_DateCheck(\$y,\$m,\$d,\$h,\$mn,\$s,\$ampm,\$wk);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5350
#   Returns 1 if any of the fields are bad.  All fields are optional, and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5351
#   all possible checks are done on the data.  If a field is not passed in,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5352
#   it is set to default values.  If data is missing, appropriate defaults
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5353
#   are supplied.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5354
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5355
#   If the flag UpdateHolidays is set, the year is set to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5356
#   CurrHolidayYear.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5357
sub Date_DateCheck {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5358
  print "DEBUG: Date_DateCheck\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5359
  my($y,$m,$d,$h,$mn,$s,$ampm,$wk)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5360
  my($tmp1,$tmp2,$tmp3)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5361
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5362
  my(@d_in_m)=(0,31,28,31,30,31,30,31,31,30,31,30,31);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5363
  my($curr_y)=$Curr{"Y"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5364
  my($curr_m)=$Curr{"M"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5365
  my($curr_d)=$Curr{"D"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5366
  $$m=1, $$d=1  if (defined $$y and ! defined $$m and ! defined $$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5367
  $$y=""     if (! defined $$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5368
  $$m=""     if (! defined $$m);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5369
  $$d=""     if (! defined $$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5370
  $$wk=""    if (! defined $$wk);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5371
  $$d=$curr_d  if ($$y eq "" and $$m eq "" and $$d eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5372
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5373
  # Check year.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5374
  $$y=$curr_y             if ($$y eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5375
  $$y=&Date_FixYear($$y)  if (length($$y)<4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5376
  return 1                if (! &IsInt($$y,0,9999));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5377
  $d_in_m[2]=29           if (&Date_LeapYear($$y));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5378
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5379
  # Check month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5380
  $$m=$curr_m             if ($$m eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5381
  $$m=$Lang{$Cnf{"Language"}}{"MonthH"}{lc($$m)}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5382
    if (exists $Lang{$Cnf{"Language"}}{"MonthH"}{lc($$m)});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5383
  $$m="0$$m"              if (length($$m)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5384
  return 1                if (! &IsInt($$m,1,12));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5385
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5386
  # Check day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5387
  $$d="01"                if ($$d eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5388
  $$d="0$$d"              if (length($$d)==1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5389
  return 1                if (! &IsInt($$d,1,$d_in_m[$$m]));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5390
  if ($$wk) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5391
    $tmp1=&Date_DayOfWeek($$m,$$d,$$y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5392
    $tmp2=$Lang{$Cnf{"Language"}}{"WeekH"}{lc($$wk)}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5393
      if (exists $Lang{$Cnf{"Language"}}{"WeekH"}{lc($$wk)});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5394
    return 1      if ($tmp1 != $tmp2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5395
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5396
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5397
  return &Date_TimeCheck($h,$mn,$s,$ampm);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5398
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5399
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5400
# Takes a year in 2 digit form and returns it in 4 digit form
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5401
sub Date_FixYear {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5402
  print "DEBUG: Date_FixYear\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5403
  my($y)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5404
  my($curr_y)=$Curr{"Y"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5405
  $y=$curr_y  if (! defined $y  or  ! $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5406
  return $y  if (length($y)==4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5407
  confess "ERROR: Invalid year ($y)\n"  if (length($y)!=2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5408
  my($y1,$y2)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5409
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5410
  if (lc($Cnf{"YYtoYYYY"}) eq "c") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5411
    $y1=substring($y,0,2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5412
    $y="$y1$y";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5413
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5414
  } elsif ($Cnf{"YYtoYYYY"} =~ /^c(\d{2})$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5415
    $y1=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5416
    $y="$y1$y";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5417
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5418
  } elsif ($Cnf{"YYtoYYYY"} =~ /^c(\d{2})(\d{2})$/i) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5419
    $y1="$1$2";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5420
    $y ="$1$y";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5421
    $y += 100  if ($y<$y1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5422
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5423
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5424
    $y1=$curr_y-$Cnf{"YYtoYYYY"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5425
    $y2=$y1+99;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5426
    $y="19$y";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5427
    while ($y<$y1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5428
      $y+=100;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5429
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5430
    while ($y>$y2) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5431
      $y-=100;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5432
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5433
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5434
  $y;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5435
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5436
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5437
# &Date_NthWeekOfYear($y,$n);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5438
#   Returns a list of (YYYY,MM,DD) for the 1st day of the Nth week of the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5439
#   year.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5440
# &Date_NthWeekOfYear($y,$n,$dow,$flag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5441
#   Returns a list of (YYYY,MM,DD) for the Nth DoW of the year.  If flag
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5442
#   is nil, the first DoW of the year may actually be in the previous
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5443
#   year (since the 1st week may include days from the previous year).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5444
#   If flag is non-nil, the 1st DoW of the year refers to the 1st one
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5445
#   actually in the year
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5446
sub Date_NthWeekOfYear {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5447
  print "DEBUG: Date_NthWeekOfYear\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5448
  my($y,$n,$dow,$flag)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5449
  my($m,$d,$err,$tmp,$date,%dow)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5450
  $y=$Curr{"Y"}  if (! defined $y  or  ! $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5451
  $n=1       if (! defined $n  or  $n eq "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5452
  return ()  if ($n<0  ||  $n>53);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5453
  if (defined $dow) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5454
    $dow=lc($dow);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5455
    %dow=%{ $Lang{$Cnf{"Language"}}{"WeekH"} };
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5456
    $dow=$dow{$dow}  if (exists $dow{$dow});
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5457
    return ()  if ($dow<1 || $dow>7);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5458
    $flag=""   if (! defined $flag);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5459
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5460
    $dow="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5461
    $flag="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5462
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5463
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5464
  $y=&Date_FixYear($y)  if (length($y)<4);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5465
  if ($Cnf{"Jan1Week1"}) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5466
    $date=&Date_Join($y,1,1,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5467
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5468
    $date=&Date_Join($y,1,4,0,0,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5469
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5470
  $date=&Date_GetPrev($date,$Cnf{"FirstDay"},1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5471
  $date=&Date_GetNext($date,$dow,1)  if ($dow ne "");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5472
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5473
  if ($flag) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5474
    ($tmp)=&Date_Split($date, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5475
    $n++  if ($tmp != $y);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5476
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5477
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5478
  if ($n>1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5479
    $date=&DateCalc_DateDelta($date,"+0:0:". ($n-1) . ":0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5480
  } elsif ($n==0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5481
    $date=&DateCalc_DateDelta($date,"-0:0:1:0:0:0:0",\$err,0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5482
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5483
  ($y,$m,$d)=&Date_Split($date, 1);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5484
  ($y,$m,$d);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5485
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5486
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5487
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5488
# LANGUAGE INITIALIZATION
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5489
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5490
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5491
# 8-bit international characters can be gotten by "\xXX".  I don't know
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5492
# how to get 16-bit characters.  I've got to read up on perllocale.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5493
sub Char_8Bit {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5494
  my($hash)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5495
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5496
  #   grave `
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5497
  #     A`    00c0     a`    00e0
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5498
  #     E`    00c8     e`    00e8
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5499
  #     I`    00cc     i`    00ec
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5500
  #     O`    00d2     o`    00f2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5501
  #     U`    00d9     u`    00f9
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5502
  #     W`    1e80     w`    1e81
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5503
  #     Y`    1ef2     y`    1ef3
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5504
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5505
  $$hash{"A`"} = "\xc0";   #   LATIN CAPITAL LETTER A WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5506
  $$hash{"E`"} = "\xc8";   #   LATIN CAPITAL LETTER E WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5507
  $$hash{"I`"} = "\xcc";   #   LATIN CAPITAL LETTER I WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5508
  $$hash{"O`"} = "\xd2";   #   LATIN CAPITAL LETTER O WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5509
  $$hash{"U`"} = "\xd9";   #   LATIN CAPITAL LETTER U WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5510
  $$hash{"a`"} = "\xe0";   #   LATIN SMALL LETTER A WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5511
  $$hash{"e`"} = "\xe8";   #   LATIN SMALL LETTER E WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5512
  $$hash{"i`"} = "\xec";   #   LATIN SMALL LETTER I WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5513
  $$hash{"o`"} = "\xf2";   #   LATIN SMALL LETTER O WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5514
  $$hash{"u`"} = "\xf9";   #   LATIN SMALL LETTER U WITH GRAVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5515
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5516
  #   acute '
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5517
  #     A'    00c1     a'    00e1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5518
  #     C'    0106     c'    0107
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5519
  #     E'    00c9     e'    00e9
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5520
  #     I'    00cd     i'    00ed
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5521
  #     L'    0139     l'    013a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5522
  #     N'    0143     n'    0144
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5523
  #     O'    00d3     o'    00f3
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5524
  #     R'    0154     r'    0155
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5525
  #     S'    015a     s'    015b
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5526
  #     U'    00da     u'    00fa
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5527
  #     W'    1e82     w'    1e83
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5528
  #     Y'    00dd     y'    00fd
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5529
  #     Z'    0179     z'    017a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5530
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5531
  $$hash{"A'"} = "\xc1";   #   LATIN CAPITAL LETTER A WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5532
  $$hash{"E'"} = "\xc9";   #   LATIN CAPITAL LETTER E WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5533
  $$hash{"I'"} = "\xcd";   #   LATIN CAPITAL LETTER I WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5534
  $$hash{"O'"} = "\xd3";   #   LATIN CAPITAL LETTER O WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5535
  $$hash{"U'"} = "\xda";   #   LATIN CAPITAL LETTER U WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5536
  $$hash{"Y'"} = "\xdd";   #   LATIN CAPITAL LETTER Y WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5537
  $$hash{"a'"} = "\xe1";   #   LATIN SMALL LETTER A WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5538
  $$hash{"e'"} = "\xe9";   #   LATIN SMALL LETTER E WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5539
  $$hash{"i'"} = "\xed";   #   LATIN SMALL LETTER I WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5540
  $$hash{"o'"} = "\xf3";   #   LATIN SMALL LETTER O WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5541
  $$hash{"u'"} = "\xfa";   #   LATIN SMALL LETTER U WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5542
  $$hash{"y'"} = "\xfd";   #   LATIN SMALL LETTER Y WITH ACUTE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5543
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5544
  #   double acute "         "
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5545
  #     O"    0150     o"    0151
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5546
  #     U"    0170     u"    0171
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5547
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5548
  #   circumflex ^
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5549
  #     A^    00c2     a^    00e2
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5550
  #     C^    0108     c^    0109
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5551
  #     E^    00ca     e^    00ea
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5552
  #     G^    011c     g^    011d
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5553
  #     H^    0124     h^    0125
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5554
  #     I^    00ce     i^    00ee
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5555
  #     J^    0134     j^    0135
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5556
  #     O^    00d4     o^    00f4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5557
  #     S^    015c     s^    015d
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5558
  #     U^    00db     u^    00fb
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5559
  #     W^    0174     w^    0175
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5560
  #     Y^    0176     y^    0177
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5561
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5562
  $$hash{"A^"} = "\xc2";   #   LATIN CAPITAL LETTER A WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5563
  $$hash{"E^"} = "\xca";   #   LATIN CAPITAL LETTER E WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5564
  $$hash{"I^"} = "\xce";   #   LATIN CAPITAL LETTER I WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5565
  $$hash{"O^"} = "\xd4";   #   LATIN CAPITAL LETTER O WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5566
  $$hash{"U^"} = "\xdb";   #   LATIN CAPITAL LETTER U WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5567
  $$hash{"a^"} = "\xe2";   #   LATIN SMALL LETTER A WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5568
  $$hash{"e^"} = "\xea";   #   LATIN SMALL LETTER E WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5569
  $$hash{"i^"} = "\xee";   #   LATIN SMALL LETTER I WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5570
  $$hash{"o^"} = "\xf4";   #   LATIN SMALL LETTER O WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5571
  $$hash{"u^"} = "\xfb";   #   LATIN SMALL LETTER U WITH CIRCUMFLEX
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5572
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5573
  #   tilde ~
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5574
  #     A~    00c3    a~    00e3
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5575
  #     I~    0128    i~    0129
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5576
  #     N~    00d1    n~    00f1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5577
  #     O~    00d5    o~    00f5
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5578
  #     U~    0168    u~    0169
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5579
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5580
  $$hash{"A~"} = "\xc3";   #   LATIN CAPITAL LETTER A WITH TILDE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5581
  $$hash{"N~"} = "\xd1";   #   LATIN CAPITAL LETTER N WITH TILDE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5582
  $$hash{"O~"} = "\xd5";   #   LATIN CAPITAL LETTER O WITH TILDE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5583
  $$hash{"a~"} = "\xe3";   #   LATIN SMALL LETTER A WITH TILDE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5584
  $$hash{"n~"} = "\xf1";   #   LATIN SMALL LETTER N WITH TILDE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5585
  $$hash{"o~"} = "\xf5";   #   LATIN SMALL LETTER O WITH TILDE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5586
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5587
  #   macron -
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5588
  #     A-    0100    a-    0101
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5589
  #     E-    0112    e-    0113
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5590
  #     I-    012a    i-    012b
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5591
  #     O-    014c    o-    014d
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5592
  #     U-    016a    u-    016b
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5593
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5594
  #   breve ( [half circle up]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5595
  #     A(    0102    a(    0103
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5596
  #     G(    011e    g(    011f
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5597
  #     U(    016c    u(    016d
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5598
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5599
  #   dot .
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5600
  #     C.    010a    c.    010b
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5601
  #     E.    0116    e.    0117
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5602
  #     G.    0120    g.    0121
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5603
  #     I.    0130
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5604
  #     Z.    017b    z.    017c
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5605
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5606
  #   diaeresis :  [side by side dots]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5607
  #     A:    00c4    a:    00e4
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5608
  #     E:    00cb    e:    00eb
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5609
  #     I:    00cf    i:    00ef
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5610
  #     O:    00d6    o:    00f6
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5611
  #     U:    00dc    u:    00fc
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5612
  #     W:    1e84    w:    1e85
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5613
  #     Y:    0178    y:    00ff
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5614
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5615
  $$hash{"A:"} = "\xc4";   #   LATIN CAPITAL LETTER A WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5616
  $$hash{"E:"} = "\xcb";   #   LATIN CAPITAL LETTER E WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5617
  $$hash{"I:"} = "\xcf";   #   LATIN CAPITAL LETTER I WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5618
  $$hash{"O:"} = "\xd6";   #   LATIN CAPITAL LETTER O WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5619
  $$hash{"U:"} = "\xdc";   #   LATIN CAPITAL LETTER U WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5620
  $$hash{"a:"} = "\xe4";   #   LATIN SMALL LETTER A WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5621
  $$hash{"e:"} = "\xeb";   #   LATIN SMALL LETTER E WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5622
  $$hash{"i:"} = "\xef";   #   LATIN SMALL LETTER I WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5623
  $$hash{"o:"} = "\xf6";   #   LATIN SMALL LETTER O WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5624
  $$hash{"u:"} = "\xfc";   #   LATIN SMALL LETTER U WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5625
  $$hash{"y:"} = "\xff";   #   LATIN SMALL LETTER Y WITH DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5626
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5627
  #   ring o
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5628
  #     U0    016e    u0    016f
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5629
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5630
  #   cedilla ,  [squiggle down and left below the letter]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5631
  #     ,C    00c7    ,c    00e7
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5632
  #     ,G    0122    ,g    0123
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5633
  #     ,K    0136    ,k    0137
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5634
  #     ,L    013b    ,l    013c
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5635
  #     ,N    0145    ,n    0146
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5636
  #     ,R    0156    ,r    0157
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5637
  #     ,S    015e    ,s    015f
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5638
  #     ,T    0162    ,t    0163
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5639
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5640
  $$hash{",C"} = "\xc7";   #   LATIN CAPITAL LETTER C WITH CEDILLA
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5641
  $$hash{",c"} = "\xe7";   #   LATIN SMALL LETTER C WITH CEDILLA
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5642
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5643
  #   ogonek ;  [squiggle down and right below the letter]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5644
  #     A;    0104    a;    0105
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5645
  #     E;    0118    e;    0119
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5646
  #     I;    012e    i;    012f
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5647
  #     U;    0172    u;    0173
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5648
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5649
  #   caron <  [little v on top]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5650
  #     A<    01cd    a<    01ce
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5651
  #     C<    010c    c<    010d
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5652
  #     D<    010e    d<    010f
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5653
  #     E<    011a    e<    011b
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5654
  #     L<    013d    l<    013e
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5655
  #     N<    0147    n<    0148
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5656
  #     R<    0158    r<    0159
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5657
  #     S<    0160    s<    0161
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5658
  #     T<    0164    t<    0165
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5659
  #     Z<    017d    z<    017e
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5660
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5661
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5662
  # Other characters
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5663
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5664
  # First character is below, 2nd character is above
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5665
  $$hash{"||"} = "\xa6";   #   BROKEN BAR
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5666
  $$hash{" :"} = "\xa8";   #   DIAERESIS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5667
  $$hash{"-a"} = "\xaa";   #   FEMININE ORDINAL INDICATOR
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5668
  #$$hash{" -"}= "\xaf";   #   MACRON   (narrow bar)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5669
  $$hash{" -"} = "\xad";   #   HYPHEN   (wide bar)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5670
  $$hash{" o"} = "\xb0";   #   DEGREE SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5671
  $$hash{"-+"} = "\xb1";   #   PLUS\342\200\220MINUS SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5672
  $$hash{" 1"} = "\xb9";   #   SUPERSCRIPT ONE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5673
  $$hash{" 2"} = "\xb2";   #   SUPERSCRIPT TWO
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5674
  $$hash{" 3"} = "\xb3";   #   SUPERSCRIPT THREE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5675
  $$hash{" '"} = "\xb4";   #   ACUTE ACCENT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5676
  $$hash{"-o"} = "\xba";   #   MASCULINE ORDINAL INDICATOR
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5677
  $$hash{" ."} = "\xb7";   #   MIDDLE DOT
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5678
  $$hash{", "} = "\xb8";   #   CEDILLA
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5679
  $$hash{"Ao"} = "\xc5";   #   LATIN CAPITAL LETTER A WITH RING ABOVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5680
  $$hash{"ao"} = "\xe5";   #   LATIN SMALL LETTER A WITH RING ABOVE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5681
  $$hash{"ox"} = "\xf0";   #   LATIN SMALL LETTER ETH
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5682
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5683
  # upside down characters
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5684
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5685
  $$hash{"ud!"} = "\xa1";  #   INVERTED EXCLAMATION MARK
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5686
  $$hash{"ud?"} = "\xbf";  #   INVERTED QUESTION MARK
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5687
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5688
  # overlay characters
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5689
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5690
  $$hash{"X o"} = "\xa4";  #   CURRENCY SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5691
  $$hash{"Y ="} = "\xa5";  #   YEN SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5692
  $$hash{"S o"} = "\xa7";  #   SECTION SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5693
  $$hash{"O c"} = "\xa9";  #   COPYRIGHT SIGN    Copyright
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5694
  $$hash{"O R"} = "\xae";  #   REGISTERED SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5695
  $$hash{"D -"} = "\xd0";  #   LATIN CAPITAL LETTER ETH
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5696
  $$hash{"O /"} = "\xd8";  #   LATIN CAPITAL LETTER O WITH STROKE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5697
  $$hash{"o /"} = "\xf8";  #   LATIN SMALL LETTER O WITH STROKE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5698
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5699
  # special names
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5700
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5701
  $$hash{"1/4"} = "\xbc";  #   VULGAR FRACTION ONE QUARTER
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5702
  $$hash{"1/2"} = "\xbd";  #   VULGAR FRACTION ONE HALF
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5703
  $$hash{"3/4"} = "\xbe";  #   VULGAR FRACTION THREE QUARTERS
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5704
  $$hash{"<<"}  = "\xab";  #   LEFT POINTING DOUBLE ANGLE QUOTATION MARK
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5705
  $$hash{">>"}  = "\xbb";  #   RIGHT POINTING DOUBLE ANGLE QUOTATION MARK
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5706
  $$hash{"cent"}= "\xa2";  #   CENT SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5707
  $$hash{"lb"}  = "\xa3";  #   POUND SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5708
  $$hash{"mu"}  = "\xb5";  #   MICRO SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5709
  $$hash{"beta"}= "\xdf";  #   LATIN SMALL LETTER SHARP S
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5710
  $$hash{"para"}= "\xb6";  #   PILCROW SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5711
  $$hash{"-|"}  = "\xac";  #   NOT SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5712
  $$hash{"AE"}  = "\xc6";  #   LATIN CAPITAL LETTER AE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5713
  $$hash{"ae"}  = "\xe6";  #   LATIN SMALL LETTER AE
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5714
  $$hash{"x"}   = "\xd7";  #   MULTIPLICATION SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5715
  $$hash{"P"}   = "\xde";  #   LATIN CAPITAL LETTER THORN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5716
  $$hash{"/"}   = "\xf7";  #   DIVISION SIGN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5717
  $$hash{"p"}   = "\xfe";  #   LATIN SMALL LETTER THORN
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5718
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5719
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5720
# $hashref = &Date_Init_LANGUAGE;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5721
#   This returns a hash containing all of the initialization for a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5722
#   specific language.  The hash elements are:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5723
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5724
#   @ month_name      full month names          January February ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5725
#   @ month_abb       month abbreviations       Jan Feb ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5726
#   @ day_name        day names                 Monday Tuesday ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5727
#   @ day_abb         day abbreviations         Mon Tue ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5728
#   @ day_char        day character abbrevs     M T ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5729
#   @ am              AM notations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5730
#   @ pm              PM notations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5731
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5732
#   @ num_suff        number with suffix        1st 2nd ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5733
#   @ num_word        numbers spelled out       first second ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5734
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5735
#   $ now             words which mean now      now today ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5736
#   $ last            words which mean last     last final ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5737
#   $ each            words which mean each     each every ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5738
#   $ of              of (as in a member of)    in of ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5739
#                     ex.  4th day OF June
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5740
#   $ at              at 4:00                   at
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5741
#   $ on              on Sunday                 on
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5742
#   $ future          in the future             in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5743
#   $ past            in the past               ago
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5744
#   $ next            next item                 next
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5745
#   $ prev            previous item             last previous
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5746
#   $ later           2 hours later
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5747
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5748
#   % offset          a hash of special dates   { tomorrow->0:0:0:1:0:0:0 }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5749
#   % times           a hash of times           { noon->12:00:00 ... }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5750
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5751
#   $ years           words for year            y yr year ...
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5752
#   $ months          words for month
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5753
#   $ weeks           words for week
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5754
#   $ days            words for day
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5755
#   $ hours           words for hour
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5756
#   $ minutes         words for minute
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5757
#   $ seconds         words for second
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5758
#   % replace
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5759
#       The replace element is quite important, but a bit tricky.  In
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5760
#       English (and probably other languages), one of the abbreviations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5761
#       for the word month that would be nice is "m".  The problem is that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5762
#       "m" matches the "m" in "minute" which causes the string to be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5763
#       improperly matched in some cases.  Hence, the list of abbreviations
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5764
#       for month is given as:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5765
#         "mon month months"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5766
#       In order to allow you to enter "m", replacements can be done.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5767
#       $replace is a list of pairs of words which are matched and replaced
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5768
#       AS ENTIRE WORDS.  Having $replace equal to "m"->"month" means that
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5769
#       the entire word "m" will be replaced with "month".  This allows the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5770
#       desired abbreviation to be used.  Make sure that replace contains
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5771
#       an even number of words (i.e. all must be pairs).  Any time a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5772
#       desired abbreviation matches the start of any other, it has to go
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5773
#       here.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5774
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5775
#   $ exact           exact mode                exactly
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5776
#   $ approx          approximate mode          approximately
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5777
#   $ business        business mode             business
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5778
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5779
#   r sephm           hour/minute separator     (?::)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5780
#   r sepms           minute/second separator   (?::)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5781
#   r sepss           second/fraction separator (?:[.:])
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5782
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5783
#   Elements marked with an asterix (@) are returned as a set of lists.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5784
#   Each list contains the strings for each element.  The first set is used
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5785
#   when the 7-bit ASCII (US) character set is wanted.  The 2nd set is used
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5786
#   when an international character set is available.  Both of the 1st two
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5787
#   sets should be complete (but the 2nd list can be left empty to force the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5788
#   first set to be used always).  The 3rd set and later can be partial sets
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5789
#   if desired.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5790
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5791
#   Elements marked with a dollar ($) are returned as a simple list of words.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5792
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5793
#   Elements marked with a percent (%) are returned as a hash list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5794
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5795
#   Elements marked with (r) are regular expression elements which must not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5796
#   create a back reference.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5797
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5798
# ***NOTE*** Every hash element (unless otherwise noted) MUST be defined in
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5799
# every language.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5800
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5801
sub Date_Init_English {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5802
  print "DEBUG: Date_Init_English\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5803
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5804
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5805
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5806
    [["January","February","March","April","May","June",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5807
      "July","August","September","October","November","December"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5808
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5809
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5810
    [["Jan","Feb","Mar","Apr","May","Jun",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5811
      "Jul","Aug","Sep","Oct","Nov","Dec"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5812
     [],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5813
     ["","","","","","","","","Sept"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5814
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5815
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5816
    [["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5817
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5818
    [["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5819
     ["",   "Tues","",  "Thur","",  "",   ""]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5820
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5821
    [["M","T","W","Th","F","Sa","S"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5822
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5823
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5824
    [["1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5825
      "11th","12th","13th","14th","15th","16th","17th","18th","19th","20th",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5826
      "21st","22nd","23rd","24th","25th","26th","27th","28th","29th","30th",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5827
      "31st"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5828
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5829
    [["first","second","third","fourth","fifth","sixth","seventh","eighth",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5830
      "ninth","tenth","eleventh","twelfth","thirteenth","fourteenth",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5831
      "fifteenth","sixteenth","seventeenth","eighteenth","nineteenth",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5832
      "twentieth","twenty-first","twenty-second","twenty-third",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5833
      "twenty-fourth","twenty-fifth","twenty-sixth","twenty-seventh",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5834
      "twenty-eighth","twenty-ninth","thirtieth","thirty-first"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5835
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5836
  $$d{"now"}     =["today","now"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5837
  $$d{"last"}    =["last","final"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5838
  $$d{"each"}    =["each","every"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5839
  $$d{"of"}      =["in","of"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5840
  $$d{"at"}      =["at"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5841
  $$d{"on"}      =["on"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5842
  $$d{"future"}  =["in"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5843
  $$d{"past"}    =["ago"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5844
  $$d{"next"}    =["next"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5845
  $$d{"prev"}    =["previous","last"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5846
  $$d{"later"}   =["later"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5847
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5848
  $$d{"exact"}   =["exactly"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5849
  $$d{"approx"}  =["approximately"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5850
  $$d{"business"}=["business"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5851
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5852
  $$d{"offset"}  =["yesterday","-0:0:0:1:0:0:0","tomorrow","+0:0:0:1:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5853
  $$d{"times"}   =["noon","12:00:00","midnight","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5854
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5855
  $$d{"years"}   =["y","yr","year","yrs","years"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5856
  $$d{"months"}  =["mon","month","months"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5857
  $$d{"weeks"}   =["w","wk","wks","week","weeks"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5858
  $$d{"days"}    =["d","day","days"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5859
  $$d{"hours"}   =["h","hr","hrs","hour","hours"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5860
  $$d{"minutes"} =["mn","min","minute","minutes"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5861
  $$d{"seconds"} =["s","sec","second","seconds"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5862
  $$d{"replace"} =["m","month"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5863
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5864
  $$d{"sephm"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5865
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5866
  $$d{"sepss"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5867
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5868
  $$d{"am"}      = ["AM","A.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5869
  $$d{"pm"}      = ["PM","P.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5870
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5871
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5872
sub Date_Init_Italian {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5873
  print "DEBUG: Date_Init_Italian\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5874
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5875
  my(%h)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5876
  &Char_8Bit(\%h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5877
  my($i)=$h{"i'"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5878
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5879
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5880
    [[qw(Gennaio Febbraio Marzo Aprile Maggio Giugno
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5881
         Luglio Agosto Settembre Ottobre Novembre Dicembre)]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5882
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5883
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5884
    [[qw(Gen Feb Mar Apr Mag Giu Lug Ago Set Ott Nov Dic)]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5885
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5886
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5887
    [[qw(Lunedi Martedi Mercoledi Giovedi Venerdi Sabato Domenica)],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5888
     [qw(Luned${i} Marted${i} Mercoled${i} Gioved${i} Venerd${i})]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5889
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5890
    [[qw(Lun Mar Mer Gio Ven Sab Dom)]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5891
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5892
    [[qw(L Ma Me G V S D)]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5893
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5894
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5895
    [[qw(1mo 2do 3zo 4to 5to 6to 7mo 8vo 9no 10mo 11mo 12mo 13mo 14mo 15mo
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5896
         16mo 17mo 18mo 19mo 20mo 21mo 22mo 23mo 24mo 25mo 26mo 27mo 28mo
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5897
         29mo 3mo 31mo)]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5898
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5899
    [[qw(primo secondo terzo quarto quinto sesto settimo ottavo nono decimo
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5900
         undicesimo dodicesimo tredicesimo quattordicesimo quindicesimo
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5901
         sedicesimo diciassettesimo diciottesimo diciannovesimo ventesimo
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5902
         ventunesimo ventiduesimo ventitreesimo ventiquattresimo
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5903
         venticinquesimo ventiseiesimo ventisettesimo ventottesimo
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5904
         ventinovesimo trentesimo trentunesimo)]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5905
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5906
  $$d{"now"}     =[qw(adesso oggi)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5907
  $$d{"last"}    =[qw(ultimo)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5908
  $$d{"each"}    =[qw(ogni)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5909
  $$d{"of"}      =[qw(della del)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5910
  $$d{"at"}      =[qw(alle)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5911
  $$d{"on"}      =[qw(di)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5912
  $$d{"future"}  =[qw(fra)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5913
  $$d{"past"}    =[qw(fa)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5914
  $$d{"next"}    =[qw(prossimo)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5915
  $$d{"prev"}    =[qw(ultimo)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5916
  $$d{"later"}   =[qw(dopo)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5917
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5918
  $$d{"exact"}   =[qw(esattamente)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5919
  $$d{"approx"}  =[qw(circa)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5920
  $$d{"business"}=[qw(lavorativi lavorativo)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5921
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5922
  $$d{"offset"}  =[qw(ieri -0:0:0:1:0:0:0 domani +0:0:0:1:0:0:0)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5923
  $$d{"times"}   =[qw(mezzogiorno 12:00:00 mezzanotte 00:00:00)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5924
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5925
  $$d{"years"}   =[qw(anni anno a)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5926
  $$d{"months"}  =[qw(mesi mese mes)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5927
  $$d{"weeks"}   =[qw(settimane settimana sett)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5928
  $$d{"days"}    =[qw(giorni giorno g)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5929
  $$d{"hours"}   =[qw(ore ora h)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5930
  $$d{"minutes"} =[qw(minuti minuto min)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5931
  $$d{"seconds"} =[qw(secondi secondo sec)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5932
  $$d{"replace"} =[qw(s sec m mes)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5933
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5934
  $$d{"sephm"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5935
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5936
  $$d{"sepss"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5937
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5938
  $$d{"am"}      = [qw(AM)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5939
  $$d{"pm"}      = [qw(PM)];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5940
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5941
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5942
sub Date_Init_French {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5943
  print "DEBUG: Date_Init_French\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5944
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5945
  my(%h)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5946
  &Char_8Bit(\%h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5947
  my($e)=$h{"e'"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5948
  my($u)=$h{"u^"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5949
  my($a)=$h{"a'"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5950
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5951
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5952
    [["janvier","fevrier","mars","avril","mai","juin",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5953
      "juillet","aout","septembre","octobre","novembre","decembre"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5954
     ["janvier","f${e}vrier","mars","avril","mai","juin",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5955
      "juillet","ao${u}t","septembre","octobre","novembre","d${e}cembre"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5956
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5957
    [["jan","fev","mar","avr","mai","juin",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5958
      "juil","aout","sept","oct","nov","dec"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5959
     ["jan","f${e}v","mar","avr","mai","juin",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5960
      "juil","ao${u}t","sept","oct","nov","d${e}c"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5961
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5962
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5963
    [["lundi","mardi","mercredi","jeudi","vendredi","samedi","dimanche"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5964
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5965
    [["lun","mar","mer","jeu","ven","sam","dim"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5966
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5967
    [["l","ma","me","j","v","s","d"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5968
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5969
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5970
    [["1er","2e","3e","4e","5e","6e","7e","8e","9e","10e",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5971
      "11e","12e","13e","14e","15e","16e","17e","18e","19e","20e",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5972
      "21e","22e","23e","24e","25e","26e","27e","28e","29e","30e",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5973
      "31e"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5974
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5975
    [["premier","deux","trois","quatre","cinq","six","sept","huit","neuf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5976
      "dix","onze","douze","treize","quatorze","quinze","seize","dix-sept",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5977
      "dix-huit","dix-neuf","vingt","vingt et un","vingt-deux","vingt-trois",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5978
      "vingt-quatre","vingt-cinq","vingt-six","vingt-sept","vingt-huit",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5979
      "vingt-neuf","trente","trente et un"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5980
     ["1re"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5981
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5982
  $$d{"now"}     =["aujourd'hui","maintenant"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5983
  $$d{"last"}    =["dernier"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5984
  $$d{"each"}    =["chaque","tous les","toutes les"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5985
  $$d{"of"}      =["en","de"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5986
  $$d{"at"}      =["a","${a}0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5987
  $$d{"on"}      =["sur"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5988
  $$d{"future"}  =["en"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5989
  $$d{"past"}    =["il y a"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5990
  $$d{"next"}    =["suivant"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5991
  $$d{"prev"}    =["precedent","pr${e}c${e}dent"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5992
  $$d{"later"}   =["plus tard"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5993
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5994
  $$d{"exact"}   =["exactement"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5995
  $$d{"approx"}  =["approximativement"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5996
  $$d{"business"}=["professionel"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5997
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5998
  $$d{"offset"}  =["hier","-0:0:0:1:0:0:0","demain","+0:0:0:1:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  5999
  $$d{"times"}   =["midi","12:00:00","minuit","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6000
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6001
  $$d{"years"}   =["an","annee","ans","annees","ann${e}e","ann${e}es"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6002
  $$d{"months"}  =["mois"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6003
  $$d{"weeks"}   =["sem","semaine"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6004
  $$d{"days"}    =["j","jour","jours"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6005
  $$d{"hours"}   =["h","heure","heures"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6006
  $$d{"minutes"} =["mn","min","minute","minutes"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6007
  $$d{"seconds"} =["s","sec","seconde","secondes"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6008
  $$d{"replace"} =["m","mois"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6009
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6010
  $$d{"sephm"}   ='[h:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6011
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6012
  $$d{"sepss"}   ='[.:,]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6013
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6014
  $$d{"am"}      = ["du matin"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6015
  $$d{"pm"}      = ["du soir"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6016
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6017
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6018
sub Date_Init_Romanian {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6019
  print "DEBUG: Date_Init_Romanian\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6020
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6021
  my(%h)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6022
  &Char_8Bit(\%h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6023
  my($p)=$h{"p"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6024
  my($i)=$h{"i^"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6025
  my($a)=$h{"a~"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6026
  my($o)=$h{"-o"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6027
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6028
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6029
    [["ianuarie","februarie","martie","aprilie","mai","iunie",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6030
      "iulie","august","septembrie","octombrie","noiembrie","decembrie"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6031
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6032
    [["ian","febr","mart","apr","mai","iun",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6033
      "iul","aug","sept","oct","nov","dec"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6034
     ["","feb"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6035
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6036
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6037
    [["luni","marti","miercuri","joi","vineri","simbata","duminica"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6038
     ["luni","mar${p}i","miercuri","joi","vineri","s${i}mb${a}t${a}",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6039
      "duminic${a}"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6040
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6041
    [["lun","mar","mie","joi","vin","sim","dum"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6042
     ["lun","mar","mie","joi","vin","s${i}m","dum"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6043
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6044
    [["L","Ma","Mi","J","V","S","D"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6045
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6046
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6047
    [["prima","a doua","a 3-a","a 4-a","a 5-a","a 6-a","a 7-a","a 8-a",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6048
      "a 9-a","a 10-a","a 11-a","a 12-a","a 13-a","a 14-a","a 15-a",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6049
      "a 16-a","a 17-a","a 18-a","a 19-a","a 20-a","a 21-a","a 22-a",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6050
      "a 23-a","a 24-a","a 25-a","a 26-a","a 27-a","a 28-a","a 29-a",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6051
      "a 30-a","a 31-a"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6052
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6053
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6054
    [["prima","a doua","a treia","a patra","a cincea","a sasea","a saptea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6055
      "a opta","a noua","a zecea","a unsprezecea","a doisprezecea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6056
      "a treisprezecea","a patrusprezecea","a cincisprezecea","a saiprezecea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6057
      "a saptesprezecea","a optsprezecea","a nouasprezecea","a douazecea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6058
      "a douazecisiuna","a douazecisidoua","a douazecisitreia",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6059
      "a douazecisipatra","a douazecisicincea","a douazecisisasea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6060
      "a douazecisisaptea","a douazecisiopta","a douazecisinoua","a treizecea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6061
      "a treizecisiuna"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6062
     ["prima","a doua","a treia","a patra","a cincea","a ${o}asea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6063
      "a ${o}aptea","a opta","a noua","a zecea","a unsprezecea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6064
      "a doisprezecea","a treisprezecea","a patrusprezecea","a cincisprezecea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6065
      "a ${o}aiprezecea","a ${o}aptesprezecea","a optsprezecea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6066
      "a nou${a}sprezecea","a dou${a}zecea","a dou${a}zeci${o}iuna",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6067
      "a dou${a}zeci${o}idoua","a dou${a}zeci${o}itreia",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6068
      "a dou${a}zeci${o}ipatra","a dou${a}zeci${o}icincea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6069
      "a dou${a}zeci${o}i${o}asea","a dou${a}zeci${o}i${o}aptea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6070
      "a dou${a}zeci${o}iopta","a dou${a}zeci${o}inoua","a treizecea",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6071
      "a treizeci${o}iuna"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6072
     ["intii", "doi", "trei", "patru", "cinci", "sase", "sapte",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6073
      "opt","noua","zece","unsprezece","doisprezece",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6074
      "treisprezece","patrusprezece","cincisprezece","saiprezece",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6075
      "saptesprezece","optsprezece","nouasprezece","douazeci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6076
      "douazecisiunu","douazecisidoi","douazecisitrei",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6077
      "douazecisipatru","douazecisicinci","douazecisisase","douazecisisapte",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6078
      "douazecisiopt","douazecisinoua","treizeci","treizecisiunu"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6079
     ["${i}nt${i}i", "doi", "trei", "patru", "cinci", "${o}ase", "${o}apte",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6080
      "opt","nou${a}","zece","unsprezece","doisprezece",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6081
      "treisprezece","patrusprezece","cincisprezece","${o}aiprezece",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6082
      "${o}aptesprezece","optsprezece","nou${a}sprezece","dou${a}zeci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6083
      "dou${a}zeci${o}iunu","dou${a}zeci${o}idoi","dou${a}zeci${o}itrei",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6084
      "dou${a}zecisipatru","dou${a}zeci${o}icinci","dou${a}zeci${o}i${o}ase",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6085
      "dou${a}zeci${o}i${o}apte","dou${a}zeci${o}iopt",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6086
      "dou${a}zeci${o}inou${a}","treizeci","treizeci${o}iunu"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6087
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6088
  $$d{"now"}     =["acum","azi","astazi","ast${a}zi"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6089
  $$d{"last"}    =["ultima"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6090
  $$d{"each"}    =["fiecare"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6091
  $$d{"of"}      =["din","in","n"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6092
  $$d{"at"}      =["la"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6093
  $$d{"on"}      =["on"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6094
  $$d{"future"}  =["in","${i}n"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6095
  $$d{"past"}    =["in urma", "${i}n urm${a}"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6096
  $$d{"next"}    =["urmatoarea","urm${a}toarea"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6097
  $$d{"prev"}    =["precedenta","ultima"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6098
  $$d{"later"}   =["mai tirziu", "mai t${i}rziu"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6099
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6100
  $$d{"exact"}   =["exact"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6101
  $$d{"approx"}  =["aproximativ"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6102
  $$d{"business"}=["de lucru","lucratoare","lucr${a}toare"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6103
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6104
  $$d{"offset"}  =["ieri","-0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6105
                   "alaltaieri", "-0:0:0:2:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6106
                   "alalt${a}ieri","-0:0:0:2:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6107
                   "miine","+0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6108
                   "m${i}ine","+0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6109
                   "poimiine","+0:0:0:2:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6110
                   "poim${i}ine","+0:0:0:2:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6111
  $$d{"times"}   =["amiaza","12:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6112
                   "amiaz${a}","12:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6113
                   "miezul noptii","00:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6114
                   "miezul nop${p}ii","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6115
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6116
  $$d{"years"}   =["ani","an","a"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6117
  $$d{"months"}  =["luni","luna","lun${a}","l"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6118
  $$d{"weeks"}   =["saptamini","s${a}pt${a}m${i}ni","saptamina",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6119
                   "s${a}pt${a}m${i}na","sapt","s${a}pt"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6120
  $$d{"days"}    =["zile","zi","z"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6121
  $$d{"hours"}   =["ore", "ora", "or${a}", "h"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6122
  $$d{"minutes"} =["minute","min","m"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6123
  $$d{"seconds"} =["secunde","sec",];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6124
  $$d{"replace"} =["s","secunde"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6125
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6126
  $$d{"sephm"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6127
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6128
  $$d{"sepss"}   ='[.:,]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6129
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6130
  $$d{"am"}      = ["AM","A.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6131
  $$d{"pm"}      = ["PM","P.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6132
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6133
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6134
sub Date_Init_Swedish {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6135
  print "DEBUG: Date_Init_Swedish\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6136
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6137
  my(%h)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6138
  &Char_8Bit(\%h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6139
  my($ao)=$h{"ao"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6140
  my($o) =$h{"o:"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6141
  my($a) =$h{"a:"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6142
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6143
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6144
    [["Januari","Februari","Mars","April","Maj","Juni",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6145
      "Juli","Augusti","September","Oktober","November","December"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6146
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6147
    [["Jan","Feb","Mar","Apr","Maj","Jun",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6148
      "Jul","Aug","Sep","Okt","Nov","Dec"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6149
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6150
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6151
    [["Mandag","Tisdag","Onsdag","Torsdag","Fredag","Lordag","Sondag"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6152
     ["M${ao}ndag","Tisdag","Onsdag","Torsdag","Fredag","L${o}rdag",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6153
      "S${o}ndag"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6154
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6155
    [["Man","Tis","Ons","Tor","Fre","Lor","Son"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6156
     ["M${ao}n","Tis","Ons","Tor","Fre","L${o}r","S${o}n"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6157
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6158
    [["M","Ti","O","To","F","L","S"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6159
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6160
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6161
    [["1:a","2:a","3:e","4:e","5:e","6:e","7:e","8:e","9:e","10:e",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6162
      "11:e","12:e","13:e","14:e","15:e","16:e","17:e","18:e","19:e","20:e",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6163
      "21:a","22:a","23:e","24:e","25:e","26:e","27:e","28:e","29:e","30:e",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6164
      "31:a"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6165
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6166
    [["forsta","andra","tredje","fjarde","femte","sjatte","sjunde",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6167
      "attonde","nionde","tionde","elfte","tolfte","trettonde","fjortonde",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6168
      "femtonde","sextonde","sjuttonde","artonde","nittonde","tjugonde",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6169
      "tjugoforsta","tjugoandra","tjugotredje","tjugofjarde","tjugofemte",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6170
      "tjugosjatte","tjugosjunde","tjugoattonde","tjugonionde",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6171
      "trettionde","trettioforsta"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6172
     ["f${o}rsta","andra","tredje","fj${a}rde","femte","sj${a}tte","sjunde",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6173
      "${ao}ttonde","nionde","tionde","elfte","tolfte","trettonde","fjortonde",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6174
      "femtonde","sextonde","sjuttonde","artonde","nittonde","tjugonde",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6175
      "tjugof${o}rsta","tjugoandra","tjugotredje","tjugofj${a}rde","tjugofemte",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6176
      "tjugosj${a}tte","tjugosjunde","tjugo${ao}ttonde","tjugonionde",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6177
      "trettionde","trettiof${o}rsta"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6178
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6179
  $$d{"now"}     =["idag","nu"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6180
  $$d{"last"}    =["forra","f${o}rra","senaste"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6181
  $$d{"each"}    =["varje"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6182
  $$d{"of"}      =["om"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6183
  $$d{"at"}      =["kl","kl.","klockan"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6184
  $$d{"on"}      =["pa","p${ao}"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6185
  $$d{"future"}  =["om"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6186
  $$d{"past"}    =["sedan"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6187
  $$d{"next"}    =["nasta","n${a}sta"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6188
  $$d{"prev"}    =["forra","f${o}rra"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6189
  $$d{"later"}   =["senare"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6190
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6191
  $$d{"exact"}   =["exakt"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6192
  $$d{"approx"}  =["ungefar","ungef${a}r"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6193
  $$d{"business"}=["arbetsdag","arbetsdagar"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6194
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6195
  $$d{"offset"}  =["ig${ao}r","-0:0:0:1:0:0:0","igar","-0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6196
                   "imorgon","+0:0:0:1:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6197
  $$d{"times"}   =["mitt pa dagen","12:00:00","mitt p${ao} dagen","12:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6198
                   "midnatt","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6199
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6200
  $$d{"years"}   =["ar","${ao}r"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6201
  $$d{"months"}  =["man","manad","manader","m${ao}n","m${ao}nad","m${ao}nader"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6202
  $$d{"weeks"}   =["v","vecka","veckor"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6203
  $$d{"days"}    =["d","dag","dagar"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6204
  $$d{"hours"}   =["t","tim","timme","timmar"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6205
  $$d{"minutes"} =["min","minut","minuter"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6206
  $$d{"seconds"} =["s","sek","sekund","sekunder"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6207
  $$d{"replace"} =["m","minut"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6208
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6209
  $$d{"sephm"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6210
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6211
  $$d{"sepss"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6212
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6213
  $$d{"am"}      = ["FM"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6214
  $$d{"pm"}      = ["EM"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6215
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6216
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6217
sub Date_Init_German {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6218
  print "DEBUG: Date_Init_German\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6219
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6220
  my(%h)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6221
  &Char_8Bit(\%h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6222
  my($a)=$h{"a:"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6223
  my($u)=$h{"u:"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6224
  my($o)=$h{"o:"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6225
  my($b)=$h{"beta"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6226
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6227
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6228
    [["Januar","Februar","Maerz","April","Mai","Juni",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6229
      "Juli","August","September","Oktober","November","Dezember"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6230
    ["J${a}nner","Februar","M${a}rz","April","Mai","Juni",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6231
      "Juli","August","September","Oktober","November","Dezember"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6232
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6233
    [["Jan","Feb","Mar","Apr","Mai","Jun",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6234
      "Jul","Aug","Sep","Okt","Nov","Dez"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6235
     ["J${a}n","Feb","M${a}r","Apr","Mai","Jun",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6236
      "Jul","Aug","Sep","Okt","Nov","Dez"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6237
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6238
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6239
    [["Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6240
      "Sonntag"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6241
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6242
    [["Mon","Die","Mit","Don","Fre","Sam","Son"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6243
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6244
    [["M","Di","Mi","Do","F","Sa","So"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6245
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6246
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6247
    [["1.","2.","3.","4.","5.","6.","7.","8.","9.","10.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6248
      "11.","12.","13.","14.","15.","16.","17.","18.","19.","20.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6249
      "21.","22.","23.","24.","25.","26.","27.","28.","29.","30.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6250
      "31."]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6251
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6252
    [
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6253
     ["erste","zweite","dritte","vierte","funfte","sechste","siebente",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6254
      "achte","neunte","zehnte","elfte","zwolfte","dreizehnte","vierzehnte",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6255
      "funfzehnte","sechzehnte","siebzehnte","achtzehnte","neunzehnte",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6256
      "zwanzigste","einundzwanzigste","zweiundzwanzigste","dreiundzwanzigste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6257
      "vierundzwanzigste","funfundzwanzigste","sechundzwanzigste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6258
      "siebundzwanzigste","achtundzwanzigste","neunundzwanzigste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6259
      "dreibigste","einunddreibigste"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6260
     ["erste","zweite","dritte","vierte","f${u}nfte","sechste","siebente",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6261
      "achte","neunte","zehnte","elfte","zw${o}lfte","dreizehnte",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6262
      "vierzehnte","f${u}nfzehnte","sechzehnte","siebzehnte","achtzehnte",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6263
      "neunzehnte","zwanzigste","einundzwanzigste","zweiundzwanzigste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6264
      "dreiundzwanzigste","vierundzwanzigste","f${u}nfundzwanzigste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6265
      "sechundzwanzigste","siebundzwanzigste","achtundzwanzigste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6266
      "neunundzwanzigste","drei${b}igste","einunddrei${b}igste"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6267
    ["erster"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6268
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6269
  $$d{"now"}     =["heute","jetzt"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6270
  $$d{"last"}    =["letzte","letzten"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6271
  $$d{"each"}    =["jeden"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6272
  $$d{"of"}      =["der","im","des"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6273
  $$d{"at"}      =["um"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6274
  $$d{"on"}      =["am"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6275
  $$d{"future"}  =["in"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6276
  $$d{"past"}    =["vor"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6277
  $$d{"next"}    =["nachste","n${a}chste","nachsten","n${a}chsten"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6278
  $$d{"prev"}    =["vorherigen","vorherige","letzte","letzten"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6279
  $$d{"later"}   =["spater","sp${a}ter"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6280
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6281
  $$d{"exact"}   =["genau"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6282
  $$d{"approx"}  =["ungefahr","ungef${a}hr"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6283
  $$d{"business"}=["Arbeitstag"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6284
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6285
  $$d{"offset"}  =["gestern","-0:0:0:1:0:0:0","morgen","+0:0:0:1:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6286
  $$d{"times"}   =["mittag","12:00:00","mitternacht","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6287
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6288
  $$d{"years"}   =["j","Jahr","Jahre"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6289
  $$d{"months"}  =["Monat","Monate"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6290
  $$d{"weeks"}   =["w","Woche","Wochen"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6291
  $$d{"days"}    =["t","Tag","Tage"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6292
  $$d{"hours"}   =["h","std","Stunde","Stunden"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6293
  $$d{"minutes"} =["min","Minute","Minuten"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6294
  $$d{"seconds"} =["s","sek","Sekunde","Sekunden"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6295
  $$d{"replace"} =["m","Monat"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6296
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6297
  $$d{"sephm"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6298
  $$d{"sepms"}   ='[: ]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6299
  $$d{"sepss"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6300
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6301
  $$d{"am"}      = ["FM"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6302
  $$d{"pm"}      = ["EM"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6303
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6304
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6305
sub Date_Init_Dutch {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6306
  print "DEBUG: Date_Init_Dutch\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6307
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6308
  my(%h)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6309
  &Char_8Bit(\%h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6310
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6311
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6312
    [["januari","februari","maart","april","mei","juni","juli","augustus",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6313
      "september","october","november","december"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6314
     ["","","","","","","","","","oktober"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6315
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6316
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6317
    [["jan","feb","maa","apr","mei","jun","jul",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6318
      "aug","sep","oct","nov","dec"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6319
     ["","","mrt","","","","","","","okt"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6320
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6321
    [["maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6322
      "zondag"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6323
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6324
    [["ma","di","wo","do","vr","zat","zon"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6325
     ["","","","","","za","zo"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6326
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6327
    [["M","D","W","D","V","Za","Zo"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6328
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6329
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6330
    [["1ste","2de","3de","4de","5de","6de","7de","8ste","9de","10de",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6331
      "11de","12de","13de","14de","15de","16de","17de","18de","19de","20ste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6332
      "21ste","22ste","23ste","24ste","25ste","26ste","27ste","28ste","29ste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6333
      "30ste","31ste"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6334
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6335
    [["eerste","tweede","derde","vierde","vijfde","zesde","zevende","achtste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6336
      "negende","tiende","elfde","twaalfde",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6337
      map {"${_}tiende";} qw (der veer vijf zes zeven acht negen),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6338
      "twintigste",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6339
      map {"${_}entwintigste";} qw (een twee drie vier vijf zes zeven acht
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6340
                                    negen),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6341
      "dertigste","eenendertigste"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6342
     ["","","","","","","","","","","","","","","","","","","","",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6343
      map {"${_}-en-twintigste";} qw (een twee drie vier vijf zes zeven acht
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6344
                                      negen),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6345
      "dertigste","een-en-dertigste"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6346
     ["een","twee","drie","vier","vijf","zes","zeven","acht","negen","tien",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6347
      "elf","twaalf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6348
      map {"${_}tien"} qw (der veer vijf zes zeven acht negen),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6349
      "twintig",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6350
      map {"${_}entwintig"} qw (een twee drie vier vijf zes zeven acht negen),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6351
      "dertig","eenendertig"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6352
     ["","","","","","","","","","","","","","","","","","","","",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6353
      map {"${_}-en-twintig"} qw (een twee drie vier vijf zes zeven acht
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6354
                                  negen),
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6355
      "dertig","een-en-dertig"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6356
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6357
  $$d{"now"}     =["nu","nou","vandaag"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6358
  $$d{"last"}    =["laatste"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6359
  $$d{"each"}    =["elke","elk"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6360
  $$d{"of"}      =["in","van"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6361
  $$d{"at"}      =["om"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6362
  $$d{"on"}      =["op"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6363
  $$d{"future"}  =["over"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6364
  $$d{"past"}    =["geleden","vroeger","eerder"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6365
  $$d{"next"}    =["volgende","volgend"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6366
  $$d{"prev"}    =["voorgaande","voorgaand"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6367
  $$d{"later"}   =["later"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6368
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6369
  $$d{"exact"}   =["exact","precies","nauwkeurig"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6370
  $$d{"approx"}  =["ongeveer","ong",'ong\.',"circa","ca",'ca\.'];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6371
  $$d{"business"}=["werk","zakelijke","zakelijk"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6372
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6373
  $$d{"offset"}  =["morgen","+0:0:0:1:0:0:0","overmorgen","+0:0:0:2:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6374
                   "gisteren","-0:0:0:1:0:0:0","eergisteren","-0::00:2:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6375
  $$d{"times"}   =["noen","12:00:00","middernacht","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6376
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6377
  $$d{"years"}   =["jaar","jaren","ja","j"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6378
  $$d{"months"}  =["maand","maanden","mnd"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6379
  $$d{"weeks"}   =["week","weken","w"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6380
  $$d{"days"}    =["dag","dagen","d"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6381
  $$d{"hours"}   =["uur","uren","u","h"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6382
  $$d{"minutes"} =["minuut","minuten","min"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6383
  $$d{"seconds"} =["seconde","seconden","sec","s"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6384
  $$d{"replace"} =["m","minuten"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6385
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6386
  $$d{"sephm"}   ='[:.uh]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6387
  $$d{"sepms"}   ='[:.m]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6388
  $$d{"sepss"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6389
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6390
  $$d{"am"}      = ["am","a.m.","vm","v.m.","voormiddag","'s_ochtends",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6391
                    "ochtend","'s_nachts","nacht"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6392
  $$d{"pm"}      = ["pm","p.m.","nm","n.m.","namiddag","'s_middags","middag",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6393
                    "'s_avonds","avond"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6394
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6395
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6396
sub Date_Init_Polish {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6397
  print "DEBUG: Date_Init_Polish\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6398
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6399
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6400
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6401
    [["stycznia","luty","marca","kwietnia","maja","czerwca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6402
      "lipca","sierpnia","wrzesnia","pazdziernika","listopada","grudnia"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6403
     ["stycznia","luty","marca","kwietnia","maja","czerwca","lipca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6404
      "sierpnia","wrze\x9cnia","pa\x9fdziernika","listopada","grudnia"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6405
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6406
    [["sty.","lut.","mar.","kwi.","maj","cze.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6407
      "lip.","sie.","wrz.","paz.","lis.","gru."],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6408
     ["sty.","lut.","mar.","kwi.","maj","cze.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6409
      "lip.","sie.","wrz.","pa\x9f.","lis.","gru."]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6410
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6411
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6412
    [["poniedzialek","wtorek","sroda","czwartek","piatek","sobota",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6413
      "niedziela"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6414
     ["poniedzia\x81\xb3ek","wtorek","\x9croda","czwartek","pi\x81\xb9tek",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6415
      "sobota","niedziela"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6416
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6417
    [["po.","wt.","sr.","cz.","pi.","so.","ni."],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6418
     ["po.","wt.","\x9cr.","cz.","pi.","so.","ni."]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6419
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6420
    [["p","w","e","c","p","s","n"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6421
     ["p","w","\x9c.","c","p","s","n"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6422
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6423
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6424
    [["1.","2.","3.","4.","5.","6.","7.","8.","9.","10.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6425
      "11.","12.","13.","14.","15.","16.","17.","18.","19.","20.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6426
      "21.","22.","23.","24.","25.","26.","27.","28.","29.","30.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6427
      "31."]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6428
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6429
    [["pierwszego","drugiego","trzeczego","czwartego","piatego","szostego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6430
      "siodmego","osmego","dziewiatego","dziesiatego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6431
      "jedenastego","dwunastego","trzynastego","czternastego","pietnastego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6432
      "szestnastego","siedemnastego","osiemnastego","dziewietnastego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6433
      "dwudziestego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6434
      "dwudziestego pierwszego","dwudziestego drugiego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6435
      "dwudziestego trzeczego","dwudziestego czwartego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6436
      "dwudziestego piatego","dwudziestego szostego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6437
      "dwudziestego siodmego","dwudziestego osmego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6438
      "dwudziestego dziewiatego","trzydziestego","trzydziestego pierwszego"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6439
     ["pierwszego","drugiego","trzeczego","czwartego","pi\x81\xb9tego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6440
      "sz\x81\xf3stego","si\x81\xf3dmego","\x81\xf3smego","dziewi\x81\xb9tego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6441
      "dziesi\x81\xb9tego","jedenastego","dwunastego","trzynastego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6442
      "czternastego","pi\x81\xeatnastego","szestnastego","siedemnastego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6443
      "osiemnastego","dziewietnastego","dwudziestego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6444
      "dwudziestego pierwszego","dwudziestego drugiego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6445
      "dwudziestego trzeczego","dwudziestego czwartego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6446
      "dwudziestego pi\x81\xb9tego","dwudziestego sz\x81\xf3stego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6447
      "dwudziestego si\x81\xf3dmego","dwudziestego \x81\xf3smego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6448
      "dwudziestego dziewi\x81\xb9tego","trzydziestego",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6449
      "trzydziestego pierwszego"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6450
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6451
  $$d{"now"}     =["dzisaj","teraz"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6452
  $$d{"last"}    =["ostatni","ostatna"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6453
  $$d{"each"}    =["kazdy","ka\x81\xbfdy", "kazdym","ka\x81\xbfdym"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6454
  $$d{"of"}      =["w","z"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6455
  $$d{"at"}      =["o","u"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6456
  $$d{"on"}      =["na"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6457
  $$d{"future"}  =["za"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6458
  $$d{"past"}    =["temu"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6459
  $$d{"next"}    =["nastepny","nast\x81\xeapny","nastepnym","nast\x81\xeapnym",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6460
                   "przyszly","przysz\x81\xb3y","przyszlym",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6461
                   "przysz\x81\xb3ym"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6462
  $$d{"prev"}    =["zeszly","zesz\x81\xb3y","zeszlym","zesz\x81\xb3ym"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6463
  $$d{"later"}   =["later"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6464
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6465
  $$d{"exact"}   =["doklandnie","dok\x81\xb3andnie"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6466
  $$d{"approx"}  =["w przyblizeniu","w przybli\x81\xbfeniu","mniej wiecej",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6467
                   "mniej wi\x81\xeacej","okolo","oko\x81\xb3o"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6468
  $$d{"business"}=["sluzbowy","s\x81\xb3u\x81\xbfbowy","sluzbowym",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6469
                   "s\x81\xb3u\x81\xbfbowym"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6470
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6471
  $$d{"times"}   =["po\x81\xb3udnie","12:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6472
                   "p\x81\xf3\x81\xb3noc","00:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6473
                   "poludnie","12:00:00","polnoc","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6474
  $$d{"offset"}  =["wczoraj","-0:0:1:0:0:0","jutro","+0:0:1:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6475
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6476
  $$d{"years"}   =["rok","lat","lata","latach"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6477
  $$d{"months"}  =["m.","miesiac","miesi\x81\xb9c","miesiecy",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6478
                   "miesi\x81\xeacy","miesiacu","miesi\x81\xb9cu"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6479
  $$d{"weeks"}   =["ty.","tydzien","tydzie\x81\xf1","tygodniu"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6480
  $$d{"days"}    =["d.","dzien","dzie\x81\xf1","dni"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6481
  $$d{"hours"}   =["g.","godzina","godziny","godzinie"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6482
  $$d{"minutes"} =["mn.","min.","minut","minuty"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6483
  $$d{"seconds"} =["s.","sekund","sekundy"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6484
  $$d{"replace"} =["m.","miesiac"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6485
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6486
  $$d{"sephm"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6487
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6488
  $$d{"sepss"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6489
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6490
  $$d{"am"}      = ["AM","A.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6491
  $$d{"pm"}      = ["PM","P.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6492
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6493
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6494
sub Date_Init_Spanish {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6495
  print "DEBUG: Date_Init_Spanish\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6496
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6497
  my(%h)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6498
  &Char_8Bit(\%h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6499
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6500
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6501
    [["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6502
      "Septiembre","Octubre","Noviembre","Diciembre"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6503
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6504
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6505
    [["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6506
      "Nov","Dic"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6507
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6508
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6509
    [["Lunes","Martes","Miercoles","Jueves","Viernes","Sabado","Domingo"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6510
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6511
    [["Lun","Mar","Mie","Jue","Vie","Sab","Dom"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6512
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6513
    [["L","Ma","Mi","J","V","S","D"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6514
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6515
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6516
    [["1o","2o","3o","4o","5o","6o","7o","8o","9o","10o",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6517
      "11o","12o","13o","14o","15o","16o","17o","18o","19o","20o",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6518
      "21o","22o","23o","24o","25o","26o","27o","28o","29o","30o","31o"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6519
     ["1a","2a","3a","4a","5a","6a","7a","8a","9a","10a",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6520
      "11a","12a","13a","14a","15a","16a","17a","18a","19a","20a",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6521
      "21a","22a","23a","24a","25a","26a","27a","28a","29a","30a","31a"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6522
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6523
    [["Primero","Segundo","Tercero","Cuarto","Quinto","Sexto","Septimo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6524
      "Octavo","Noveno","Decimo","Decimo Primero","Decimo Segundo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6525
      "Decimo Tercero","Decimo Cuarto","Decimo Quinto","Decimo Sexto",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6526
      "Decimo Septimo","Decimo Octavo","Decimo Noveno","Vigesimo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6527
      "Vigesimo Primero","Vigesimo Segundo","Vigesimo Tercero",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6528
      "Vigesimo Cuarto","Vigesimo Quinto","Vigesimo Sexto",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6529
      "Vigesimo Septimo","Vigesimo Octavo","Vigesimo Noveno","Trigesimo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6530
      "Trigesimo Primero"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6531
     ["Primera","Segunda","Tercera","Cuarta","Quinta","Sexta","Septima",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6532
      "Octava","Novena","Decima","Decimo Primera","Decimo Segunda",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6533
      "Decimo Tercera","Decimo Cuarta","Decimo Quinta","Decimo Sexta",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6534
      "Decimo Septima","Decimo Octava","Decimo Novena","Vigesima",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6535
      "Vigesimo Primera","Vigesimo Segunda","Vigesimo Tercera",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6536
      "Vigesimo Cuarta","Vigesimo Quinta","Vigesimo Sexta",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6537
      "Vigesimo Septima","Vigesimo Octava","Vigesimo Novena","Trigesima",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6538
      "Trigesimo Primera"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6539
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6540
  $$d{"now"}     =["Hoy","Ahora"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6541
  $$d{"last"}    =["ultimo"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6542
  $$d{"each"}    =["cada"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6543
  $$d{"of"}      =["en","de"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6544
  $$d{"at"}      =["a"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6545
  $$d{"on"}      =["el"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6546
  $$d{"future"}  =["en"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6547
  $$d{"past"}    =["hace"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6548
  $$d{"next"}    =["siguiente"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6549
  $$d{"prev"}    =["anterior"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6550
  $$d{"later"}   =["later"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6551
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6552
  $$d{"exact"}   =["exactamente"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6553
  $$d{"approx"}  =["aproximadamente"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6554
  $$d{"business"}=["laborales"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6555
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6556
  $$d{"offset"}  =["ayer","-0:0:0:1:0:0:0","manana","+0:0:0:1:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6557
  $$d{"times"}   =["mediodia","12:00:00","medianoche","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6558
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6559
  $$d{"years"}   =["a","ano","ano","anos","anos"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6560
  $$d{"months"}  =["m","mes","mes","meses"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6561
  $$d{"weeks"}   =["sem","semana","semana","semanas"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6562
  $$d{"days"}    =["d","dia","dias"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6563
  $$d{"hours"}   =["hr","hrs","hora","horas"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6564
  $$d{"minutes"} =["min","min","minuto","minutos"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6565
  $$d{"seconds"} =["s","seg","segundo","segundos"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6566
  $$d{"replace"} =["m","mes"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6567
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6568
  $$d{"sephm"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6569
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6570
  $$d{"sepss"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6571
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6572
  $$d{"am"}      = ["AM","A.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6573
  $$d{"pm"}      = ["PM","P.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6574
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6575
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6576
sub Date_Init_Portuguese {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6577
  print "DEBUG: Date_Init_Portuguese\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6578
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6579
  my(%h)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6580
  &Char_8Bit(\%h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6581
  my($o) = $h{"-o"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6582
  my($c) = $h{",c"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6583
  my($a) = $h{"a'"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6584
  my($e) = $h{"e'"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6585
  my($u) = $h{"u'"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6586
  my($o2)= $h{"o'"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6587
  my($a2)= $h{"a`"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6588
  my($a3)= $h{"a~"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6589
  my($e2)= $h{"e^"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6590
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6591
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6592
    [["Janeiro","Fevereiro","Marco","Abril","Maio","Junho",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6593
      "Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6594
     ["Janeiro","Fevereiro","Mar${c}o","Abril","Maio","Junho",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6595
      "Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6596
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6597
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6598
    [["Jan","Fev","Mar","Abr","Mai","Jun",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6599
      "Jul","Ago","Set","Out","Nov","Dez"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6600
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6601
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6602
    [["Segunda","Terca","Quarta","Quinta","Sexta","Sabado","Domingo"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6603
     ["Segunda","Ter${c}a","Quarta","Quinta","Sexta","S${a}bado","Domingo"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6604
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6605
    [["Seg","Ter","Qua","Qui","Sex","Sab","Dom"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6606
     ["Seg","Ter","Qua","Qui","Sex","S${a}b","Dom"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6607
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6608
    [["Sg","T","Qa","Qi","Sx","Sb","D"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6609
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6610
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6611
    [["1${o}","2${o}","3${o}","4${o}","5${o}","6${o}","7${o}","8${o}",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6612
      "9${o}","10${o}","11${o}","12${o}","13${o}","14${o}","15${o}",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6613
      "16${o}","17${o}","18${o}","19${o}","20${o}","21${o}","22${o}",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6614
      "23${o}","24${o}","25${o}","26${o}","27${o}","28${o}","29${o}",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6615
      "30${o}","31${o}"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6616
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6617
    [["primeiro","segundo","terceiro","quarto","quinto","sexto","setimo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6618
      "oitavo","nono","decimo","decimo primeiro","decimo segundo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6619
      "decimo terceiro","decimo quarto","decimo quinto","decimo sexto",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6620
      "decimo setimo","decimo oitavo","decimo nono","vigesimo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6621
      "vigesimo primeiro","vigesimo segundo","vigesimo terceiro",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6622
      "vigesimo quarto","vigesimo quinto","vigesimo sexto","vigesimo setimo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6623
      "vigesimo oitavo","vigesimo nono","trigesimo","trigesimo primeiro"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6624
     ["primeiro","segundo","terceiro","quarto","quinto","sexto","s${e}timo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6625
      "oitavo","nono","d${e}cimo","d${e}cimo primeiro","d${e}cimo segundo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6626
      "d${e}cimo terceiro","d${e}cimo quarto","d${e}cimo quinto",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6627
      "d${e}cimo sexto","d${e}cimo s${e}timo","d${e}cimo oitavo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6628
      "d${e}cimo nono","vig${e}simo","vig${e}simo primeiro",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6629
      "vig${e}simo segundo","vig${e}simo terceiro","vig${e}simo quarto",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6630
      "vig${e}simo quinto","vig${e}simo sexto","vig${e}simo s${e}timo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6631
      "vig${e}simo oitavo","vig${e}simo nono","trig${e}simo",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6632
      "trig${e}simo primeiro"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6633
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6634
  $$d{"now"}     =["agora","hoje"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6635
  $$d{"last"}    =["${u}ltimo","ultimo"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6636
  $$d{"each"}    =["cada"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6637
  $$d{"of"}      =["da","do"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6638
  $$d{"at"}      =["as","${a2}s"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6639
  $$d{"on"}      =["na","no"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6640
  $$d{"future"}  =["em"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6641
  $$d{"past"}    =["a","${a2}"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6642
  $$d{"next"}    =["proxima","proximo","pr${o2}xima","pr${o2}ximo"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6643
  $$d{"prev"}    =["ultima","ultimo","${u}ltima","${u}ltimo"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6644
  $$d{"later"}   =["passadas","passados"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6645
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6646
  $$d{"exact"}   =["exactamente"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6647
  $$d{"approx"}  =["aproximadamente"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6648
  $$d{"business"}=["util","uteis"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6649
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6650
  $$d{"offset"}  =["ontem","-0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6651
                   "amanha","+0:0:0:1:0:0:0","amanh${a3}","+0:0:0:1:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6652
  $$d{"times"}   =["meio-dia","12:00:00","meia-noite","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6653
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6654
  $$d{"years"}   =["anos","ano","ans","an","a"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6655
  $$d{"months"}  =["meses","m${e2}s","mes","m"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6656
  $$d{"weeks"}   =["semanas","semana","sem","sems","s"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6657
  $$d{"days"}    =["dias","dia","d"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6658
  $$d{"hours"}   =["horas","hora","hr","hrs"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6659
  $$d{"minutes"} =["minutos","minuto","min","mn"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6660
  $$d{"seconds"} =["segundos","segundo","seg","sg"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6661
  $$d{"replace"} =["m","mes","s","sems"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6662
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6663
  $$d{"sephm"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6664
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6665
  $$d{"sepss"}   ='[,]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6666
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6667
  $$d{"am"}      = ["AM","A.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6668
  $$d{"pm"}      = ["PM","P.M."];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6669
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6670
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6671
sub Date_Init_Russian {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6672
  print "DEBUG: Date_Init_Russian\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6673
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6674
  my(%h)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6675
  &Char_8Bit(\%h);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6676
  my($a) =$h{"a:"};
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6677
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6678
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6679
    [
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6680
     ["\xd1\xce\xd7\xc1\xd2\xd1","\xc6\xc5\xd7\xd2\xc1\xcc\xd1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6681
      "\xcd\xc1\xd2\xd4\xc1","\xc1\xd0\xd2\xc5\xcc\xd1","\xcd\xc1\xd1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6682
      "\xc9\xc0\xce\xd1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6683
      "\xc9\xc0\xcc\xd1","\xc1\xd7\xc7\xd5\xd3\xd4\xc1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6684
      "\xd3\xc5\xce\xd4\xd1\xc2\xd2\xd1","\xcf\xcb\xd4\xd1\xc2\xd2\xd1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6685
      "\xce\xcf\xd1\xc2\xd2\xd1","\xc4\xc5\xcb\xc1\xc2\xd2\xd1"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6686
     ["\xd1\xce\xd7\xc1\xd2\xd8","\xc6\xc5\xd7\xd2\xc1\xcc\xd8",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6687
      "\xcd\xc1\xd2\xd4","\xc1\xd0\xd2\xc5\xcc\xd8","\xcd\xc1\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6688
      "\xc9\xc0\xce\xd8",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6689
      "\xc9\xc0\xcc\xd8","\xc1\xd7\xc7\xd5\xd3\xd4",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6690
      "\xd3\xc5\xce\xd4\xd1\xc2\xd2\xd8","\xcf\xcb\xd4\xd1\xc2\xd2\xd8",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6691
      "\xce\xcf\xd1\xc2\xd2\xd8","\xc4\xc5\xcb\xc1\xc2\xd2\xd8"]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6692
    ];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6693
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6694
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6695
    [["\xd1\xce\xd7","\xc6\xc5\xd7","\xcd\xd2\xd4","\xc1\xd0\xd2",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6696
      "\xcd\xc1\xca","\xc9\xc0\xce",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6697
      "\xc9\xc0\xcc","\xc1\xd7\xc7","\xd3\xce\xd4","\xcf\xcb\xd4",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6698
      "\xce\xcf\xd1\xc2","\xc4\xc5\xcb"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6699
     ["","\xc6\xd7\xd2","","","\xcd\xc1\xd1","",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6700
      "","","\xd3\xc5\xce","\xcf\xcb\xd4","\xce\xcf\xd1",""]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6701
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6702
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6703
    [["\xd0\xcf\xce\xc5\xc4\xc5\xcc\xd8\xce\xc9\xcb",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6704
      "\xd7\xd4\xcf\xd2\xce\xc9\xcb","\xd3\xd2\xc5\xc4\xc1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6705
      "\xde\xc5\xd4\xd7\xc5\xd2\xc7","\xd0\xd1\xd4\xce\xc9\xc3\xc1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6706
      "\xd3\xd5\xc2\xc2\xcf\xd4\xc1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6707
      "\xd7\xcf\xd3\xcb\xd2\xc5\xd3\xc5\xce\xd8\xc5"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6708
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6709
    [["\xd0\xce\xc4","\xd7\xd4\xd2","\xd3\xd2\xc4","\xde\xd4\xd7",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6710
      "\xd0\xd4\xce","\xd3\xd5\xc2","\xd7\xd3\xcb"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6711
     ["\xd0\xcf\xce","\xd7\xd4\xcf","\xd3\xd2e","\xde\xc5\xd4",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6712
      "\xd0\xd1\xd4","\xd3\xd5\xc2","\xd7\xcf\xd3\xcb"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6713
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6714
    [["\xd0\xce","\xd7\xd4","\xd3\xd2","\xde\xd4","\xd0\xd4","\xd3\xc2",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6715
      "\xd7\xd3"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6716
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6717
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6718
    [["1 ","2 ","3 ","4 ","5 ","6 ","7 ","8 ","9 ","10 ",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6719
      "11 ","12 ","13 ","14 ","15 ","16 ","17 ","18 ","19 ","20 ",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6720
      "21 ","22 ","23 ","24 ","25 ","26 ","27 ","28 ","29 ","30 ",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6721
      "31 "]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6722
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6723
    [["\xd0\xc5\xd2\xd7\xd9\xca","\xd7\xd4\xcf\xd2\xcf\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6724
      "\xd4\xd2\xc5\xd4\xc9\xca","\xde\xc5\xd4\xd7\xc5\xd2\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6725
      "\xd0\xd1\xd4\xd9\xca","\xdb\xc5\xd3\xd4\xcf\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6726
      "\xd3\xc5\xc4\xd8\xcd\xcf\xca","\xd7\xcf\xd3\xd8\xcd\xcf\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6727
      "\xc4\xc5\xd7\xd1\xd4\xd9\xca","\xc4\xc5\xd3\xd1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6728
      "\xcf\xc4\xc9\xce\xce\xc1\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6729
      "\xc4\xd7\xc5\xce\xc1\xc4\xde\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6730
      "\xd4\xd2\xc5\xce\xc1\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6731
      "\xde\xc5\xd4\xd9\xd2\xce\xc1\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6732
      "\xd0\xd1\xd4\xce\xc1\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6733
      "\xdb\xc5\xd3\xd4\xce\xc1\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6734
      "\xd3\xc5\xcd\xd8\xce\xc1\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6735
      "\xd7\xcf\xd3\xc5\xcd\xd8\xce\xc1\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6736
      "\xc4\xc5\xd7\xd1\xd4\xce\xc1\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6737
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6738
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd0\xc5\xd2\xd7\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6739
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd7\xd4\xcf\xd2\xcf\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6740
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd4\xd2\xc5\xd4\xc9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6741
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xde\xc5\xd4\xd7\xc5\xd2\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6742
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd0\xd1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6743
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xdb\xc5\xd3\xd4\xcf\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6744
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd3\xc5\xc4\xd8\xcd\xcf\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6745
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd7\xcf\xd3\xd8\xcd\xcf\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6746
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xc4\xc5\xd7\xd1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6747
      "\xd4\xd2\xc9\xc4\xc3\xc1\xd4\xd9\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6748
      "\xd4\xd2\xc9\xc4\xc3\xc1\xd4\xd8 \xd0\xc5\xd2\xd7\xd9\xca"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6749
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6750
     ["\xd0\xc5\xd2\xd7\xcf\xc5","\xd7\xd4\xcf\xd2\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6751
      "\xd4\xd2\xc5\xd4\xd8\xc5","\xde\xc5\xd4\xd7\xc5\xd2\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6752
      "\xd0\xd1\xd4\xcf\xc5","\xdb\xc5\xd3\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6753
      "\xd3\xc5\xc4\xd8\xcd\xcf\xc5","\xd7\xcf\xd3\xd8\xcd\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6754
      "\xc4\xc5\xd7\xd1\xd4\xcf\xc5","\xc4\xc5\xd3\xd1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6755
      "\xcf\xc4\xc9\xce\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6756
      "\xc4\xd7\xc5\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6757
      "\xd4\xd2\xc5\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6758
      "\xde\xc5\xd4\xd9\xd2\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6759
      "\xd0\xd1\xd4\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6760
      "\xdb\xc5\xd3\xd4\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6761
      "\xd3\xc5\xcd\xd8\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6762
      "\xd7\xcf\xd3\xc5\xcd\xd8\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6763
      "\xc4\xc5\xd7\xd1\xd4\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6764
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6765
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd0\xc5\xd2\xd7\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6766
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd7\xd4\xcf\xd2\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6767
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd4\xd2\xc5\xd4\xd8\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6768
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xde\xc5\xd4\xd7\xc5\xd2\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6769
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd0\xd1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6770
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xdb\xc5\xd3\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6771
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd3\xc5\xc4\xd8\xcd\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6772
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd7\xcf\xd3\xd8\xcd\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6773
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xc4\xc5\xd7\xd1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6774
      "\xd4\xd2\xc9\xc4\xc3\xc1\xd4\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6775
      "\xd4\xd2\xc9\xc4\xc3\xc1\xd4\xd8 \xd0\xc5\xd2\xd7\xcf\xc5"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6776
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6777
     ["\xd0\xc5\xd2\xd7\xcf\xc7\xcf","\xd7\xd4\xcf\xd2\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6778
      "\xd4\xd2\xc5\xd4\xd8\xc5\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6779
      "\xde\xc5\xd4\xd7\xc5\xd2\xd4\xcf\xc7\xcf","\xd0\xd1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6780
      "\xdb\xc5\xd3\xd4\xcf\xc7\xcf","\xd3\xc5\xc4\xd8\xcd\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6781
      "\xd7\xcf\xd3\xd8\xcd\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6782
      "\xc4\xc5\xd7\xd1\xd4\xcf\xc7\xcf","\xc4\xc5\xd3\xd1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6783
      "\xcf\xc4\xc9\xce\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6784
      "\xc4\xd7\xc5\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6785
      "\xd4\xd2\xc5\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6786
      "\xde\xc5\xd4\xd9\xd2\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6787
      "\xd0\xd1\xd4\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6788
      "\xdb\xc5\xd3\xd4\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6789
      "\xd3\xc5\xcd\xd8\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6790
      "\xd7\xcf\xd3\xc5\xcd\xd8\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6791
      "\xc4\xc5\xd7\xd1\xd4\xce\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6792
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6793
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd0\xc5\xd2\xd7\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6794
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd7\xd4\xcf\xd2\xcf\xc5",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6795
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd4\xd2\xc5\xd4\xd8\xc5\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6796
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xde\xc5\xd4\xd7\xc5\xd2\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6797
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd0\xd1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6798
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xdb\xc5\xd3\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6799
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd3\xc5\xc4\xd8\xcd\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6800
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xd7\xcf\xd3\xd8\xcd\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6801
      "\xc4\xd7\xc1\xc4\xc3\xc1\xd4\xd8 \xc4\xc5\xd7\xd1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6802
      "\xd4\xd2\xc9\xc4\xc3\xc1\xd4\xcf\xc7\xcf",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6803
      "\xd4\xd2\xc9\xc4\xc3\xc1\xd4\xd8 \xd0\xc5\xd2\xd7\xcf\xc7\xcf"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6804
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6805
  $$d{"now"}     =["\xd3\xc5\xc7\xcf\xc4\xce\xd1","\xd3\xc5\xca\xde\xc1\xd3"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6806
  $$d{"last"}    =["\xd0\xcf\xd3\xcc\xc5\xc4\xce\xc9\xca"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6807
  $$d{"each"}    =["\xcb\xc1\xd6\xc4\xd9\xca"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6808
  $$d{"of"}      =[" "];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6809
  $$d{"at"}      =["\xd7"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6810
  $$d{"on"}      =["\xd7"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6811
  $$d{"future"}  =["\xd7\xd0\xc5\xd2\xc5\xc4 \xce\xc1"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6812
  $$d{"past"}    =["\xce\xc1\xda\xc1\xc4 \xce\xc1 "];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6813
  $$d{"next"}    =["\xd3\xcc\xc5\xc4\xd5\xc0\xdd\xc9\xca"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6814
  $$d{"prev"}    =["\xd0\xd2\xc5\xc4\xd9\xc4\xd5\xdd\xc9\xca"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6815
  $$d{"later"}   =["\xd0\xcf\xda\xd6\xc5"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6816
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6817
  $$d{"exact"}   =["\xd4\xcf\xde\xce\xcf"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6818
  $$d{"approx"}  =["\xd0\xd2\xc9\xcd\xc5\xd2\xce\xcf"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6819
  $$d{"business"}=["\xd2\xc1\xc2\xcf\xde\xc9\xc8"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6820
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6821
  $$d{"offset"}  =["\xd0\xcf\xda\xc1\xd7\xde\xc5\xd2\xc1","-0:0:0:2:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6822
                   "\xd7\xde\xc5\xd2\xc1","-0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6823
                   "\xda\xc1\xd7\xd4\xd2\xc1","+0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6824
                   "\xd0\xcf\xd3\xcc\xc5\xda\xc1\xd7\xd4\xd2\xc1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6825
                   "+0:0:0:2:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6826
  $$d{"times"}   =["\xd0\xcf\xcc\xc4\xc5\xce\xd8","12:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6827
                   "\xd0\xcf\xcc\xce\xcf\xde\xd8","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6828
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6829
  $$d{"years"}   =["\xc7","\xc7\xc4","\xc7\xcf\xc4","\xcc\xc5\xd4",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6830
                   "\xcc\xc5\xd4","\xc7\xcf\xc4\xc1"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6831
  $$d{"months"}  =["\xcd\xc5\xd3","\xcd\xc5\xd3\xd1\xc3",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6832
                   "\xcd\xc5\xd3\xd1\xc3\xc5\xd7"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6833
  $$d{"weeks"}   =["\xce\xc5\xc4\xc5\xcc\xd1","\xce\xc5\xc4\xc5\xcc\xd8",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6834
                   "\xce\xc5\xc4\xc5\xcc\xc9","\xce\xc5\xc4\xc5\xcc\xc0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6835
  $$d{"days"}    =["\xc4","\xc4\xc5\xce\xd8","\xc4\xce\xc5\xca",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6836
                   "\xc4\xce\xd1"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6837
  $$d{"hours"}   =["\xde","\xde.","\xde\xd3","\xde\xd3\xd7","\xde\xc1\xd3",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6838
                   "\xde\xc1\xd3\xcf\xd7","\xde\xc1\xd3\xc1"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6839
  $$d{"minutes"} =["\xcd\xce","\xcd\xc9\xce","\xcd\xc9\xce\xd5\xd4\xc1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6840
                   "\xcd\xc9\xce\xd5\xd4"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6841
  $$d{"seconds"} =["\xd3","\xd3\xc5\xcb","\xd3\xc5\xcb\xd5\xce\xc4\xc1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6842
                   "\xd3\xc5\xcb\xd5\xce\xc4"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6843
  $$d{"replace"} =[];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6844
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6845
  $$d{"sephm"}   ="[:\xde]";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6846
  $$d{"sepms"}   ="[:\xcd]";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6847
  $$d{"sepss"}   ="[:.\xd3]";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6848
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6849
  $$d{"am"}      = ["\xc4\xd0","${a}\xf0","${a}.\xf0.","\xce\xcf\xde\xc9",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6850
                    "\xd5\xd4\xd2\xc1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6851
                    "\xc4\xcf \xd0\xcf\xcc\xd5\xc4\xce\xd1"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6852
  $$d{"pm"}      = ["\xd0\xd0","\xf0\xf0","\xf0.\xf0.","\xc4\xce\xd1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6853
                    "\xd7\xc5\xde\xc5\xd2\xc1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6854
                    "\xd0\xcf\xd3\xcc\xc5 \xd0\xcf\xcc\xd5\xc4\xce\xd1",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6855
                    "\xd0\xcf \xd0\xcf\xcc\xd5\xc4\xce\xc0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6856
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6857
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6858
sub Date_Init_Turkish {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6859
  print "DEBUG: Date_Init_Turkish\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6860
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6861
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6862
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6863
    [
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6864
     ["ocak","subat","mart","nisan","mayis","haziran",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6865
      "temmuz","agustos","eylul","ekim","kasim","aralik"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6866
     ["ocak","\xfeubat","mart","nisan","may\xfds","haziran",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6867
      "temmuz","a\xf0ustos","eyl\xfcl","ekim","kas\xfdm","aral\xfdk"]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6868
     ];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6869
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6870
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6871
    [
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6872
     ["oca","sub","mar","nis","may","haz",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6873
      "tem","agu","eyl","eki","kas","ara"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6874
     ["oca","\xfeub","mar","nis","may","haz",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6875
      "tem","a\xf0u","eyl","eki","kas","ara"]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6876
     ];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6877
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6878
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6879
    [
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6880
     ["pazartesi","sali","carsamba","persembe","cuma","cumartesi","pazar"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6881
     ["pazartesi","sal\xfd","\xe7ar\xfeamba","per\xfeembe","cuma",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6882
      "cumartesi","pazar"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6883
     ];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6884
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6885
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6886
    [
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6887
     ["pzt","sal","car","per","cum","cts","paz"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6888
     ["pzt","sal","\xe7ar","per","cum","cts","paz"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6889
     ];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6890
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6891
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6892
    [["Pt","S","Cr","Pr","C","Ct","P"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6893
     ["Pt","S","\xc7","Pr","C","Ct","P"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6894
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6895
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6896
    [[ "1.", "2.", "3.", "4.", "5.", "6.", "7.", "8.", "9.", "10.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6897
       "11.", "12.", "13.", "14.", "15.", "16.", "17.", "18.", "19.", "20.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6898
       "21.", "22.", "23.", "24.", "25.", "26.", "27.", "28.", "29.", "30.",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6899
       "31."]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6900
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6901
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6902
    [
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6903
     ["birinci","ikinci","ucuncu","dorduncu",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6904
      "besinci","altinci","yedinci","sekizinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6905
      "dokuzuncu","onuncu","onbirinci","onikinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6906
      "onucuncu","ondordoncu",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6907
      "onbesinci","onaltinci","onyedinci","onsekizinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6908
      "ondokuzuncu","yirminci","yirmibirinci","yirmikinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6909
      "yirmiucuncu","yirmidorduncu",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6910
      "yirmibesinci","yirmialtinci","yirmiyedinci","yirmisekizinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6911
      "yirmidokuzuncu","otuzuncu","otuzbirinci"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6912
     ["birinci","ikinci","\xfc\xe7\xfcnc\xfc","d\xf6rd\xfcnc\xfc",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6913
      "be\xfeinci","alt\xfdnc\xfd","yedinci","sekizinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6914
      "dokuzuncu","onuncu","onbirinci","onikinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6915
      "on\xfc\xe7\xfcnc\xfc","ond\xf6rd\xfcnc\xfc",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6916
      "onbe\xfeinci","onalt\xfdnc\xfd","onyedinci","onsekizinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6917
      "ondokuzuncu","yirminci","yirmibirinci","yirmikinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6918
      "yirmi\xfc\xe7\xfcnc\xfc","yirmid\xf6rd\xfcnc\xfc",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6919
      "yirmibe\xfeinci","yirmialt\xfdnc\xfd","yirmiyedinci","yirmisekizinci",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6920
      "yirmidokuzuncu","otuzuncu","otuzbirinci"]
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6921
     ];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6922
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6923
  $$d{"now"}     =["\xfeimdi", "simdi", "bugun","bug\xfcn"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6924
  $$d{"last"}    =["son", "sonuncu"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6925
  $$d{"each"}    =["her"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6926
  $$d{"of"}      =["of"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6927
  $$d{"at"}      =["saat"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6928
  $$d{"on"}      =["on"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6929
  $$d{"future"}  =["gelecek"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6930
  $$d{"past"}    =["ge\xe7mi\xfe", "gecmis","gecen", "ge\xe7en"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6931
  $$d{"next"}    =["gelecek","sonraki"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6932
  $$d{"prev"}    =["onceki","\xf6nceki"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6933
  $$d{"later"}   =["sonra"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6934
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6935
  $$d{"exact"}   =["tam"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6936
  $$d{"approx"}  =["yakla\xfe\xfdk", "yaklasik"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6937
  $$d{"business"}=["i\xfe","\xe7al\xfd\xfema","is", "calisma"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6938
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6939
  $$d{"offset"}  =["d\xfcn","-0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6940
                   "dun", "-0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6941
                   "yar\xfdn","+0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6942
                   "yarin","+0:0:0:1:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6943
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6944
  $$d{"times"}   =["\xf6\xf0len","12:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6945
                   "oglen","12:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6946
                   "yarim","12:300:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6947
                   "yar\xfdm","12:30:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6948
                   "gece yar\xfds\xfd","00:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6949
                   "gece yarisi","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6950
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6951
  $$d{"years"}   =["yil","y"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6952
  $$d{"months"}  =["ay","a"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6953
  $$d{"weeks"}   =["hafta", "h"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6954
  $$d{"days"}    =["gun","g"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6955
  $$d{"hours"}   =["saat"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6956
  $$d{"minutes"} =["dakika","dak","d"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6957
  $$d{"seconds"} =["saniye","sn",];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6958
  $$d{"replace"} =["s","saat"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6959
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6960
  $$d{"sephm"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6961
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6962
  $$d{"sepss"}   ='[.:,]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6963
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6964
  $$d{"am"}      = ["\xf6gleden \xf6nce","ogleden once"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6965
  $$d{"pm"}      = ["\xf6\xf0leden sonra","ogleden sonra"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6966
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6967
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6968
sub Date_Init_Danish {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6969
  print "DEBUG: Date_Init_Danish\n"  if ($Curr{"Debug"} =~ /trace/);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6970
  my($d)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6971
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6972
  $$d{"month_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6973
    [["Januar","Februar","Marts","April","Maj","Juni",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6974
      "Juli","August","September","Oktober","November","December"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6975
  $$d{"month_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6976
    [["Jan","Feb","Mar","Apr","Maj","Jun",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6977
      "Jul","Aug","Sep","Okt","Nov","Dec"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6978
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6979
  $$d{"day_name"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6980
    [["Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lordag","Sondag"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6981
     ["Mandag","Tirsdag","Onsdag","Torsdag","Fredag","L\xf8rdag","S\xf8ndag"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6982
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6983
  $$d{"day_abb"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6984
    [["Man","Tis","Ons","Tor","Fre","Lor","Son"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6985
     ["Man","Tis","Ons","Tor","Fre","L\xf8r","S\xf8n"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6986
  $$d{"day_char"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6987
    [["M","Ti","O","To","F","L","S"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6988
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6989
  $$d{"num_suff"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6990
    [["1:e","2:e","3:e","4:e","5:e","6:e","7:e","8:e","9:e","10:e",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6991
      "11:e","12:e","13:e","14:e","15:e","16:e","17:e","18:e","19:e","20:e",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6992
      "21:e","22:e","23:e","24:e","25:e","26:e","27:e","28:e","29:e","30:e",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6993
      "31:e"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6994
  $$d{"num_word"}=
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6995
    [["forste","anden","tredie","fjerde","femte","sjette","syvende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6996
      "ottende","niende","tiende","elfte","tolvte","trettende","fjortende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6997
      "femtende","sekstende","syttende","attende","nittende","tyvende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6998
      "enogtyvende","toogtyvende","treogtyvende","fireogtyvende","femogtyvende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  6999
      "seksogtyvende","syvogtyvende","otteogtyvende","niogtyvende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7000
      "tredivte","enogtredivte"],
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7001
     ["f\xf8rste","anden","tredie","fjerde","femte","sjette","syvende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7002
      "ottende","niende","tiende","elfte","tolvte","trettende","fjortende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7003
      "femtende","sekstende","syttende","attende","nittende","tyvende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7004
      "enogtyvende","toogtyvende","treogtyvende","fireogtyvende","femogtyvende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7005
      "seksogtyvende","syvogtyvende","otteogtyvende","niogtyvende",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7006
      "tredivte","enogtredivte"]];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7007
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7008
  $$d{"now"}     =["idag","nu"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7009
  $$d{"last"}    =["forrige","sidste","nyeste"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7010
  $$d{"each"}    =["hver"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7011
  $$d{"of"}      =["om"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7012
  $$d{"at"}      =["kl","kl.","klokken"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7013
  $$d{"on"}      =["pa","p\xe5"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7014
  $$d{"future"}  =["om"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7015
  $$d{"past"}    =["siden"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7016
  $$d{"next"}    =["nasta","n\xe6ste"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7017
  $$d{"prev"}    =["forrige"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7018
  $$d{"later"}   =["senere"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7019
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7020
  $$d{"exact"}   =["pracist","pr\xe6cist"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7021
  $$d{"approx"}  =["circa"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7022
  $$d{"business"}=["arbejdsdag","arbejdsdage"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7023
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7024
  $$d{"offset"}  =["ig\xe5r","-0:0:0:1:0:0:0","igar","-0:0:0:1:0:0:0",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7025
                   "imorgen","+0:0:0:1:0:0:0"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7026
  $$d{"times"}   =["midt pa dagen","12:00:00","midt p\xe5 dagen","12:00:00",
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7027
                   "midnat","00:00:00"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7028
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7029
  $$d{"years"}   =["ar","\xe5r"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7030
  $$d{"months"}  =["man","maned","maneder","m\xe5n","m\xe5ned","m\xe5neder"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7031
  $$d{"weeks"}   =["u","uge","uger"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7032
  $$d{"days"}    =["d","dag","dage"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7033
  $$d{"hours"}   =["t","tim","time","timer"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7034
  $$d{"minutes"} =["min","minut","minutter"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7035
  $$d{"seconds"} =["s","sek","sekund","sekunder"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7036
  $$d{"replace"} =["m","minut"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7037
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7038
  $$d{"sephm"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7039
  $$d{"sepms"}   =':';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7040
  $$d{"sepss"}   ='[.:]';
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7041
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7042
  $$d{"am"}      = ["FM"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7043
  $$d{"pm"}      = ["EM"];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7044
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7045
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7046
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7047
# FROM MY PERSONAL LIBRARIES
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7048
########################################################################
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7049
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7050
no integer;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7051
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7052
# &ModuloAddition($N,$add,\$val,\$rem);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7053
#   This calculates $val=$val+$add and forces $val to be in a certain range.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7054
#   This is useful for adding numbers for which only a certain range is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7055
#   allowed (for example, minutes can be between 0 and 59 or months can be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7056
#   between 1 and 12).  The absolute value of $N determines the range and
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7057
#   the sign of $N determines whether the range is 0 to N-1 (if N>0) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7058
#   1 to N (N<0).  The remainder (as modulo N) is added to $rem.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7059
#   Example:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7060
#     To add 2 hours together (with the excess returned in days) use:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7061
#       &ModuloAddition(60,$s1,\$s,\$day);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7062
sub ModuloAddition {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7063
  my($N,$add,$val,$rem)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7064
  return  if ($N==0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7065
  $$val+=$add;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7066
  if ($N<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7067
    # 1 to N
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7068
    $N = -$N;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7069
    if ($$val>$N) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7070
      $$rem+= int(($$val-1)/$N);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7071
      $$val = ($$val-1)%$N +1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7072
    } elsif ($$val<1) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7073
      $$rem-= int(-$$val/$N)+1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7074
      $$val = $N-(-$$val % $N);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7075
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7076
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7077
  } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7078
    # 0 to N-1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7079
    if ($$val>($N-1)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7080
      $$rem+= int($$val/$N);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7081
      $$val = $$val%$N;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7082
    } elsif ($$val<0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7083
      $$rem-= int(-($$val+1)/$N)+1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7084
      $$val = ($N-1)-(-($$val+1)%$N);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7085
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7086
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7087
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7088
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7089
# $Flag=&IsInt($String [,$low, $high]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7090
#    Returns 1 if $String is a valid integer, 0 otherwise.  If $low is
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7091
#    entered, $String must be >= $low.  If $high is entered, $String must
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7092
#    be <= $high.  It is valid to check only one of the bounds.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7093
sub IsInt {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7094
  my($N,$low,$high)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7095
  return 0  if (! defined $N  or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7096
                $N !~ /^\s*[-+]?\d+\s*$/  or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7097
                defined $low   &&  $N<$low  or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7098
                defined $high  &&  $N>$high);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7099
  return 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7100
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7101
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7102
# $Pos=&SinLindex(\@List,$Str [,$offset [,$CaseInsensitive]]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7103
#    Searches for an exact string in a list.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7104
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7105
#    This is similar to RinLindex except that it searches for elements
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7106
#    which are exactly equal to $Str (possibly case insensitive).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7107
sub SinLindex {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7108
  my($listref,$Str,$offset,$Insensitive)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7109
  my($i,$len,$tmp)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7110
  $len=$#$listref;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7111
  return -2  if ($len<0 or ! $Str);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7112
  return -1  if (&Index_First(\$offset,$len));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7113
  $Str=uc($Str)  if ($Insensitive);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7114
  for ($i=$offset; $i<=$len; $i++) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7115
    $tmp=$$listref[$i];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7116
    $tmp=uc($tmp)  if ($Insensitive);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7117
    return $i  if ($tmp eq $Str);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7118
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7119
  return -1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7120
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7121
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7122
sub Index_First {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7123
  my($offsetref,$max)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7124
  $$offsetref=0  if (! $$offsetref);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7125
  if ($$offsetref < 0) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7126
    $$offsetref += $max + 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7127
    $$offsetref=0  if ($$offsetref < 0);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7128
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7129
  return -1 if ($$offsetref > $max);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7130
  return 0;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7131
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7132
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7133
# $File=&CleanFile($file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7134
#   This cleans up a path to remove the following things:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7135
#     double slash       /a//b  -> /a/b
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7136
#     trailing dot       /a/.   -> /a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7137
#     leading dot        ./a    -> a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7138
#     trailing slash     a/     -> a
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7139
sub CleanFile {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7140
  my($file)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7141
  $file =~ s/\s*$//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7142
  $file =~ s/^\s*//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7143
  $file =~ s|//+|/|g;  # multiple slash
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7144
  $file =~ s|/\.$|/|;  # trailing /. (leaves trailing slash)
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7145
  $file =~ s|^\./||    # leading ./
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7146
    if ($file ne "./");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7147
  $file =~ s|/$||      # trailing slash
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7148
    if ($file ne "/");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7149
  return $file;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7150
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7151
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7152
# $File=&ExpandTilde($file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7153
#   This checks to see if a "~" appears as the first character in a path.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7154
#   If it does, the "~" expansion is interpreted (if possible) and the full
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7155
#   path is returned.  If a "~" expansion is used but cannot be
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7156
#   interpreted, an empty string is returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7157
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7158
#   This is Windows/Mac friendly.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7159
#   This is efficient.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7160
sub ExpandTilde {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7161
  my($file)=shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7162
  my($user,$home)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7163
  # ~aaa/bbb=      ~  aaa      /bbb
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7164
  if ($file =~ s|^~([^/]*)||) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7165
    $user=$1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7166
    # Single user operating systems (Mac, MSWindows) don't have the getpwnam
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7167
    # and getpwuid routines defined.  Try to catch various different ways
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7168
    # of knowing we are on one of these systems:
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7169
    return ""  if ($OS eq "Windows"  or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7170
                   $OS eq "Mac"  or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7171
                   $OS eq "Netware"  or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7172
                   $OS eq "MPE");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7173
    $user=""  if (! defined $user);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7174
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7175
    if ($user) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7176
      $home= (getpwnam($user))[7];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7177
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7178
      $home= (getpwuid($<))[7];
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7179
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7180
    $home = VMS::Filespec::unixpath($home)  if ($OS eq "VMS");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7181
    return ""  if (! $home);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7182
    $file="$home/$file";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7183
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7184
  $file;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7185
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7186
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7187
# $File=&FullFilePath($file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7188
#   Returns the full or relative path to $file (expanding "~" if necessary).
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7189
#   Returns an empty string if a "~" expansion cannot be interpreted.  The
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7190
#   path does not need to exist.  CleanFile is called.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7191
sub FullFilePath {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7192
  my($file)=shift;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7193
  my($rootpat) = '^/'; #default pattern to match absolute path
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7194
  $rootpat = '^(\\|/|([A-Za-z]:[\\/]))' if ($OS eq 'Windows');
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7195
  $file=&ExpandTilde($file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7196
  return ""  if (! $file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7197
  return &CleanFile($file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7198
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7199
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7200
# $Flag=&CheckFilePath($file [,$mode]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7201
#   Checks to see if $file exists, to see what type it is, and whether
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7202
#   the script can access it.  If it exists and has the correct mode, 1
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7203
#   is returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7204
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7205
#   $mode is a string which may contain any of the valid file test operator
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7206
#   characters except t, M, A, C.  The appropriate test is run for each
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7207
#   character.  For example, if $mode is "re" the -r and -e tests are both
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7208
#   run.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7209
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7210
#   An empty string is returned if the file doesn't exist.  A 0 is returned
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7211
#   if the file exists but any test fails.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7212
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7213
#   All characters in $mode which do not correspond to valid tests are
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7214
#   ignored.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7215
sub CheckFilePath {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7216
  my($file,$mode)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7217
  my($test)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7218
  $file=&FullFilePath($file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7219
  $mode = ""  if (! defined $mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7220
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7221
  # Run tests
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7222
  return 0  if (! defined $file or ! $file);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7223
  return 0  if ((                  ! -e $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7224
                ($mode =~ /r/  &&  ! -r $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7225
                ($mode =~ /w/  &&  ! -w $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7226
                ($mode =~ /x/  &&  ! -x $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7227
                ($mode =~ /R/  &&  ! -R $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7228
                ($mode =~ /W/  &&  ! -W $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7229
                ($mode =~ /X/  &&  ! -X $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7230
                ($mode =~ /o/  &&  ! -o $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7231
                ($mode =~ /O/  &&  ! -O $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7232
                ($mode =~ /z/  &&  ! -z $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7233
                ($mode =~ /s/  &&  ! -s $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7234
                ($mode =~ /f/  &&  ! -f $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7235
                ($mode =~ /d/  &&  ! -d $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7236
                ($mode =~ /l/  &&  ! -l $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7237
                ($mode =~ /s/  &&  ! -s $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7238
                ($mode =~ /p/  &&  ! -p $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7239
                ($mode =~ /b/  &&  ! -b $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7240
                ($mode =~ /c/  &&  ! -c $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7241
                ($mode =~ /u/  &&  ! -u $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7242
                ($mode =~ /g/  &&  ! -g $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7243
                ($mode =~ /k/  &&  ! -k $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7244
                ($mode =~ /T/  &&  ! -T $file) or
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7245
                ($mode =~ /B/  &&  ! -B $file));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7246
  return 1;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7247
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7248
#&&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7249
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7250
# $Path=&FixPath($path [,$full] [,$mode] [,$error]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7251
#   Makes sure that every directory in $path (a colon separated list of
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7252
#   directories) appears as a full path or relative path.  All "~"
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7253
#   expansions are removed.  All trailing slashes are removed also.  If
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7254
#   $full is non-nil, relative paths are expanded to full paths as well.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7255
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7256
#   If $mode is given, it may be either "e", "r", or "w".  In this case,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7257
#   additional checking is done to each directory.  If $mode is "e", it
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7258
#   need ony exist to pass the check.  If $mode is "r", it must have have
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7259
#   read and execute permission.  If $mode is "w", it must have read,
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7260
#   write, and execute permission.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7261
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7262
#   The value of $error determines what happens if the directory does not
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7263
#   pass the test.  If it is non-nil, if any directory does not pass the
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7264
#   test, the subroutine returns the empty string.  Otherwise, it is simply
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7265
#   removed from $path.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7266
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7267
#   The corrected path is returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7268
sub FixPath {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7269
  my($path,$full,$mode,$err)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7270
  local($_)="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7271
  my(@dir)=split(/$Cnf{"PathSep"}/,$path);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7272
  $full=0  if (! defined $full);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7273
  $mode="" if (! defined $mode);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7274
  $err=0   if (! defined $err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7275
  $path="";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7276
  if ($mode eq "e") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7277
    $mode="de";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7278
  } elsif ($mode eq "r") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7279
    $mode="derx";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7280
  } elsif ($mode eq "w") {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7281
    $mode="derwx";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7282
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7283
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7284
  foreach (@dir) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7285
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7286
    # Expand path
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7287
    if ($full) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7288
      $_=&FullFilePath($_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7289
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7290
      $_=&ExpandTilde($_);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7291
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7292
    if (! $_) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7293
      return ""  if ($err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7294
      next;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7295
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7296
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7297
    # Check mode
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7298
    if (! $mode  or  &CheckFilePath($_,$mode)) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7299
      $path .= $Cnf{"PathSep"} . $_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7300
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7301
      return "" if ($err);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7302
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7303
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7304
  $path =~ s/^$Cnf{"PathSep"}//;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7305
  return $path;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7306
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7307
#&&
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7308
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7309
# $File=&SearchPath($file,$path [,$mode] [,@suffixes]);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7310
#   Searches through directories in $path for a file named $file.  The
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7311
#   full path is returned if one is found, or an empty string otherwise.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7312
#   The file may exist with one of the @suffixes.  The mode is checked
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7313
#   similar to &CheckFilePath.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7314
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7315
#   The first full path that matches the name and mode is returned.  If none
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7316
#   is found, an empty string is returned.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7317
sub SearchPath {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7318
  my($file,$path,$mode,@suff)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7319
  my($f,$s,$d,@dir,$fs)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7320
  $path=&FixPath($path,1,"r");
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7321
  @dir=split(/$Cnf{"PathSep"}/,$path);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7322
  foreach $d (@dir) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7323
    $f="$d/$file";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7324
    $f=~ s|//|/|g;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7325
    return $f if (&CheckFilePath($f,$mode));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7326
    foreach $s (@suff) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7327
      $fs="$f.$s";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7328
      return $fs if (&CheckFilePath($fs,$mode));
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7329
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7330
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7331
  return "";
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7332
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7333
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7334
# @list=&ReturnList($str);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7335
#    This takes a string which should be a comma separated list of integers
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7336
#    or ranges (5-7).  It returns a sorted list of all integers referred to
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7337
#    by the string, or () if there is an invalid element.
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7338
#
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7339
#    Negative integers are also handled.  "-2--1" is equivalent to "-2,-1".
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7340
sub ReturnList {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7341
  my($str)=@_;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7342
  my(@ret,@str,$from,$to,$tmp)=();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7343
  @str=split(/,/,$str);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7344
  foreach $str (@str) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7345
    if ($str =~ /^[-+]?\d+$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7346
      push(@ret,$str);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7347
    } elsif ($str =~ /^([-+]?\d+)-([-+]?\d+)$/) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7348
      ($from,$to)=($1,$2);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7349
      if ($from>$to) {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7350
        $tmp=$from;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7351
        $from=$to;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7352
        $to=$tmp;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7353
      }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7354
      push(@ret,$from..$to);
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7355
    } else {
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7356
      return ();
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7357
    }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7358
  }
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7359
  @ret;
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7360
}
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7361
3f65fd25dfd4 sync up SVN codes
kelvzhu
parents:
diff changeset
  7362
1;