| 1 |
/* |
| 2 |
* tclGetDate.y -- |
| 3 |
* |
| 4 |
* Contains yacc grammar for parsing date and time strings. The output of |
| 5 |
* this file should be the file tclDate.c which is used directly in the |
| 6 |
* Tcl sources. Note that this file is largely obsolete in Tcl 8.5; it is |
| 7 |
* only used when doing free-form date parsing, an ill-defined process |
| 8 |
* anyway. |
| 9 |
* |
| 10 |
* Copyright (c) 1992-1995 Karl Lehenbauer & Mark Diekhans. |
| 11 |
* Copyright (c) 1995-1997 Sun Microsystems, Inc. |
| 12 |
* |
| 13 |
* See the file "license.terms" for information on usage and redistribution of |
| 14 |
* this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 15 |
*/ |
| 16 |
|
| 17 |
%parse-param {DateInfo* info} |
| 18 |
%lex-param {DateInfo* info} |
| 19 |
%define api.pure |
| 20 |
/* %error-verbose would be nice, but our token names are meaningless */ |
| 21 |
%locations |
| 22 |
|
| 23 |
%{ |
| 24 |
/* |
| 25 |
* tclDate.c -- |
| 26 |
* |
| 27 |
* This file is generated from a yacc grammar defined in the file |
| 28 |
* tclGetDate.y. It should not be edited directly. |
| 29 |
* |
| 30 |
* Copyright (c) 1992-1995 Karl Lehenbauer & Mark Diekhans. |
| 31 |
* Copyright (c) 1995-1997 Sun Microsystems, Inc. |
| 32 |
* |
| 33 |
* See the file "license.terms" for information on usage and redistribution of |
| 34 |
* this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 35 |
* |
| 36 |
*/ |
| 37 |
#include "tclInt.h" |
| 38 |
|
| 39 |
/* |
| 40 |
* Bison generates several labels that happen to be unused. Several compilers |
| 41 |
* don't like that, and complain. Simply disable the warning to silence them. |
| 42 |
*/ |
| 43 |
|
| 44 |
#ifdef _MSC_VER |
| 45 |
#pragma warning( disable : 4102 ) |
| 46 |
#elif defined (__clang__) && (__clang_major__ > 14) |
| 47 |
#pragma clang diagnostic ignored "-Wunused-but-set-variable" |
| 48 |
#elif (__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))) |
| 49 |
#pragma GCC diagnostic ignored "-Wunused-but-set-variable" |
| 50 |
#endif |
| 51 |
|
| 52 |
/* |
| 53 |
* Meridian: am, pm, or 24-hour style. |
| 54 |
*/ |
| 55 |
|
| 56 |
typedef enum _MERIDIAN { |
| 57 |
MERam, MERpm, MER24 |
| 58 |
} MERIDIAN; |
| 59 |
|
| 60 |
/* |
| 61 |
* yyparse will accept a 'struct DateInfo' as its parameter; that's where the |
| 62 |
* parsed fields will be returned. |
| 63 |
*/ |
| 64 |
|
| 65 |
typedef struct DateInfo { |
| 66 |
|
| 67 |
Tcl_Obj* messages; /* Error messages */ |
| 68 |
const char* separatrix; /* String separating messages */ |
| 69 |
|
| 70 |
time_t dateYear; |
| 71 |
time_t dateMonth; |
| 72 |
time_t dateDay; |
| 73 |
int dateHaveDate; |
| 74 |
|
| 75 |
time_t dateHour; |
| 76 |
time_t dateMinutes; |
| 77 |
time_t dateSeconds; |
| 78 |
MERIDIAN dateMeridian; |
| 79 |
int dateHaveTime; |
| 80 |
|
| 81 |
time_t dateTimezone; |
| 82 |
int dateDSTmode; |
| 83 |
int dateHaveZone; |
| 84 |
|
| 85 |
time_t dateRelMonth; |
| 86 |
time_t dateRelDay; |
| 87 |
time_t dateRelSeconds; |
| 88 |
int dateHaveRel; |
| 89 |
|
| 90 |
time_t dateMonthOrdinal; |
| 91 |
int dateHaveOrdinalMonth; |
| 92 |
|
| 93 |
time_t dateDayOrdinal; |
| 94 |
time_t dateDayNumber; |
| 95 |
int dateHaveDay; |
| 96 |
|
| 97 |
const char *dateStart; |
| 98 |
const char *dateInput; |
| 99 |
time_t *dateRelPointer; |
| 100 |
|
| 101 |
int dateDigitCount; |
| 102 |
} DateInfo; |
| 103 |
|
| 104 |
#define YYMALLOC ckalloc |
| 105 |
#define YYFREE(x) (ckfree((void*) (x))) |
| 106 |
|
| 107 |
#define yyDSTmode (info->dateDSTmode) |
| 108 |
#define yyDayOrdinal (info->dateDayOrdinal) |
| 109 |
#define yyDayNumber (info->dateDayNumber) |
| 110 |
#define yyMonthOrdinal (info->dateMonthOrdinal) |
| 111 |
#define yyHaveDate (info->dateHaveDate) |
| 112 |
#define yyHaveDay (info->dateHaveDay) |
| 113 |
#define yyHaveOrdinalMonth (info->dateHaveOrdinalMonth) |
| 114 |
#define yyHaveRel (info->dateHaveRel) |
| 115 |
#define yyHaveTime (info->dateHaveTime) |
| 116 |
#define yyHaveZone (info->dateHaveZone) |
| 117 |
#define yyTimezone (info->dateTimezone) |
| 118 |
#define yyDay (info->dateDay) |
| 119 |
#define yyMonth (info->dateMonth) |
| 120 |
#define yyYear (info->dateYear) |
| 121 |
#define yyHour (info->dateHour) |
| 122 |
#define yyMinutes (info->dateMinutes) |
| 123 |
#define yySeconds (info->dateSeconds) |
| 124 |
#define yyMeridian (info->dateMeridian) |
| 125 |
#define yyRelMonth (info->dateRelMonth) |
| 126 |
#define yyRelDay (info->dateRelDay) |
| 127 |
#define yyRelSeconds (info->dateRelSeconds) |
| 128 |
#define yyRelPointer (info->dateRelPointer) |
| 129 |
#define yyInput (info->dateInput) |
| 130 |
#define yyDigitCount (info->dateDigitCount) |
| 131 |
|
| 132 |
#define EPOCH 1970 |
| 133 |
#define START_OF_TIME 1902 |
| 134 |
#define END_OF_TIME 2037 |
| 135 |
|
| 136 |
/* |
| 137 |
* The offset of tm_year of struct tm returned by localtime, gmtime, etc. |
| 138 |
* Posix requires 1900. |
| 139 |
*/ |
| 140 |
|
| 141 |
#define TM_YEAR_BASE 1900 |
| 142 |
|
| 143 |
#define HOUR(x) ((60 * (int)(x))) |
| 144 |
#define IsLeapYear(x) (((x) % 4 == 0) && ((x) % 100 != 0 || (x) % 400 == 0)) |
| 145 |
|
| 146 |
/* |
| 147 |
* An entry in the lexical lookup table. |
| 148 |
*/ |
| 149 |
|
| 150 |
typedef struct _TABLE { |
| 151 |
const char *name; |
| 152 |
int type; |
| 153 |
time_t value; |
| 154 |
} TABLE; |
| 155 |
|
| 156 |
/* |
| 157 |
* Daylight-savings mode: on, off, or not yet known. |
| 158 |
*/ |
| 159 |
|
| 160 |
typedef enum _DSTMODE { |
| 161 |
DSTon, DSToff, DSTmaybe |
| 162 |
} DSTMODE; |
| 163 |
|
| 164 |
%} |
| 165 |
|
| 166 |
%union { |
| 167 |
time_t Number; |
| 168 |
enum _MERIDIAN Meridian; |
| 169 |
} |
| 170 |
|
| 171 |
%{ |
| 172 |
|
| 173 |
/* |
| 174 |
* Prototypes of internal functions. |
| 175 |
*/ |
| 176 |
|
| 177 |
static int LookupWord(YYSTYPE* yylvalPtr, char *buff); |
| 178 |
static void TclDateerror(YYLTYPE* location, |
| 179 |
DateInfo* info, const char *s); |
| 180 |
static int TclDatelex(YYSTYPE* yylvalPtr, YYLTYPE* location, |
| 181 |
DateInfo* info); |
| 182 |
static time_t ToSeconds(time_t Hours, time_t Minutes, |
| 183 |
time_t Seconds, MERIDIAN Meridian); |
| 184 |
MODULE_SCOPE int yyparse(DateInfo*); |
| 185 |
|
| 186 |
%} |
| 187 |
|
| 188 |
%token tAGO |
| 189 |
%token tDAY |
| 190 |
%token tDAYZONE |
| 191 |
%token tID |
| 192 |
%token tMERIDIAN |
| 193 |
%token tMONTH |
| 194 |
%token tMONTH_UNIT |
| 195 |
%token tSTARDATE |
| 196 |
%token tSEC_UNIT |
| 197 |
%token tSNUMBER |
| 198 |
%token tUNUMBER |
| 199 |
%token tZONE |
| 200 |
%token tEPOCH |
| 201 |
%token tDST |
| 202 |
%token tISOBASE |
| 203 |
%token tDAY_UNIT |
| 204 |
%token tNEXT |
| 205 |
|
| 206 |
%type <Number> tDAY |
| 207 |
%type <Number> tDAYZONE |
| 208 |
%type <Number> tMONTH |
| 209 |
%type <Number> tMONTH_UNIT |
| 210 |
%type <Number> tDST |
| 211 |
%type <Number> tSEC_UNIT |
| 212 |
%type <Number> tSNUMBER |
| 213 |
%type <Number> tUNUMBER |
| 214 |
%type <Number> tZONE |
| 215 |
%type <Number> tISOBASE |
| 216 |
%type <Number> tDAY_UNIT |
| 217 |
%type <Number> unit |
| 218 |
%type <Number> sign |
| 219 |
%type <Number> tNEXT |
| 220 |
%type <Number> tSTARDATE |
| 221 |
%type <Meridian> tMERIDIAN |
| 222 |
%type <Meridian> o_merid |
| 223 |
|
| 224 |
%% |
| 225 |
|
| 226 |
spec : /* NULL */ |
| 227 |
| spec item |
| 228 |
; |
| 229 |
|
| 230 |
item : time { |
| 231 |
yyHaveTime++; |
| 232 |
} |
| 233 |
| zone { |
| 234 |
yyHaveZone++; |
| 235 |
} |
| 236 |
| date { |
| 237 |
yyHaveDate++; |
| 238 |
} |
| 239 |
| ordMonth { |
| 240 |
yyHaveOrdinalMonth++; |
| 241 |
} |
| 242 |
| day { |
| 243 |
yyHaveDay++; |
| 244 |
} |
| 245 |
| relspec { |
| 246 |
yyHaveRel++; |
| 247 |
} |
| 248 |
| iso { |
| 249 |
yyHaveTime++; |
| 250 |
yyHaveDate++; |
| 251 |
} |
| 252 |
| trek { |
| 253 |
yyHaveTime++; |
| 254 |
yyHaveDate++; |
| 255 |
yyHaveRel++; |
| 256 |
} |
| 257 |
| number |
| 258 |
; |
| 259 |
|
| 260 |
time : tUNUMBER tMERIDIAN { |
| 261 |
yyHour = $1; |
| 262 |
yyMinutes = 0; |
| 263 |
yySeconds = 0; |
| 264 |
yyMeridian = $2; |
| 265 |
} |
| 266 |
| tUNUMBER ':' tUNUMBER o_merid { |
| 267 |
yyHour = $1; |
| 268 |
yyMinutes = $3; |
| 269 |
yySeconds = 0; |
| 270 |
yyMeridian = $4; |
| 271 |
} |
| 272 |
| tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid { |
| 273 |
yyHour = $1; |
| 274 |
yyMinutes = $3; |
| 275 |
yySeconds = $5; |
| 276 |
yyMeridian = $6; |
| 277 |
} |
| 278 |
; |
| 279 |
|
| 280 |
zone : tZONE tDST { |
| 281 |
yyTimezone = $1; |
| 282 |
if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); |
| 283 |
yyDSTmode = DSTon; |
| 284 |
} |
| 285 |
| tZONE { |
| 286 |
yyTimezone = $1; |
| 287 |
if (yyTimezone > HOUR( 12)) yyTimezone -= HOUR(100); |
| 288 |
yyDSTmode = DSToff; |
| 289 |
} |
| 290 |
| tDAYZONE { |
| 291 |
yyTimezone = $1; |
| 292 |
yyDSTmode = DSTon; |
| 293 |
} |
| 294 |
| sign tUNUMBER { |
| 295 |
yyTimezone = -$1*($2 % 100 + ($2 / 100) * 60); |
| 296 |
yyDSTmode = DSToff; |
| 297 |
} |
| 298 |
; |
| 299 |
|
| 300 |
day : tDAY { |
| 301 |
yyDayOrdinal = 1; |
| 302 |
yyDayNumber = $1; |
| 303 |
} |
| 304 |
| tDAY ',' { |
| 305 |
yyDayOrdinal = 1; |
| 306 |
yyDayNumber = $1; |
| 307 |
} |
| 308 |
| tUNUMBER tDAY { |
| 309 |
yyDayOrdinal = $1; |
| 310 |
yyDayNumber = $2; |
| 311 |
} |
| 312 |
| sign tUNUMBER tDAY { |
| 313 |
yyDayOrdinal = $1 * $2; |
| 314 |
yyDayNumber = $3; |
| 315 |
} |
| 316 |
| tNEXT tDAY { |
| 317 |
yyDayOrdinal = 2; |
| 318 |
yyDayNumber = $2; |
| 319 |
} |
| 320 |
; |
| 321 |
|
| 322 |
date : tUNUMBER '/' tUNUMBER { |
| 323 |
yyMonth = $1; |
| 324 |
yyDay = $3; |
| 325 |
} |
| 326 |
| tUNUMBER '/' tUNUMBER '/' tUNUMBER { |
| 327 |
yyMonth = $1; |
| 328 |
yyDay = $3; |
| 329 |
yyYear = $5; |
| 330 |
} |
| 331 |
| tISOBASE { |
| 332 |
yyYear = $1 / 10000; |
| 333 |
yyMonth = ($1 % 10000)/100; |
| 334 |
yyDay = $1 % 100; |
| 335 |
} |
| 336 |
| tUNUMBER '-' tMONTH '-' tUNUMBER { |
| 337 |
yyDay = $1; |
| 338 |
yyMonth = $3; |
| 339 |
yyYear = $5; |
| 340 |
} |
| 341 |
| tUNUMBER '-' tUNUMBER '-' tUNUMBER { |
| 342 |
yyMonth = $3; |
| 343 |
yyDay = $5; |
| 344 |
yyYear = $1; |
| 345 |
} |
| 346 |
| tMONTH tUNUMBER { |
| 347 |
yyMonth = $1; |
| 348 |
yyDay = $2; |
| 349 |
} |
| 350 |
| tMONTH tUNUMBER ',' tUNUMBER { |
| 351 |
yyMonth = $1; |
| 352 |
yyDay = $2; |
| 353 |
yyYear = $4; |
| 354 |
} |
| 355 |
| tUNUMBER tMONTH { |
| 356 |
yyMonth = $2; |
| 357 |
yyDay = $1; |
| 358 |
} |
| 359 |
| tEPOCH { |
| 360 |
yyMonth = 1; |
| 361 |
yyDay = 1; |
| 362 |
yyYear = EPOCH; |
| 363 |
} |
| 364 |
| tUNUMBER tMONTH tUNUMBER { |
| 365 |
yyMonth = $2; |
| 366 |
yyDay = $1; |
| 367 |
yyYear = $3; |
| 368 |
} |
| 369 |
; |
| 370 |
|
| 371 |
ordMonth: tNEXT tMONTH { |
| 372 |
yyMonthOrdinal = 1; |
| 373 |
yyMonth = $2; |
| 374 |
} |
| 375 |
| tNEXT tUNUMBER tMONTH { |
| 376 |
yyMonthOrdinal = $2; |
| 377 |
yyMonth = $3; |
| 378 |
} |
| 379 |
; |
| 380 |
|
| 381 |
iso : tUNUMBER '-' tUNUMBER '-' tUNUMBER tZONE |
| 382 |
tUNUMBER ':' tUNUMBER ':' tUNUMBER { |
| 383 |
if ($6 != HOUR( 7) + HOUR(100)) YYABORT; |
| 384 |
yyYear = $1; |
| 385 |
yyMonth = $3; |
| 386 |
yyDay = $5; |
| 387 |
yyHour = $7; |
| 388 |
yyMinutes = $9; |
| 389 |
yySeconds = $11; |
| 390 |
} |
| 391 |
| tISOBASE tZONE tISOBASE { |
| 392 |
if ($2 != HOUR( 7) + HOUR(100)) YYABORT; |
| 393 |
yyYear = $1 / 10000; |
| 394 |
yyMonth = ($1 % 10000)/100; |
| 395 |
yyDay = $1 % 100; |
| 396 |
yyHour = $3 / 10000; |
| 397 |
yyMinutes = ($3 % 10000)/100; |
| 398 |
yySeconds = $3 % 100; |
| 399 |
} |
| 400 |
| tISOBASE tZONE tUNUMBER ':' tUNUMBER ':' tUNUMBER { |
| 401 |
if ($2 != HOUR( 7) + HOUR(100)) YYABORT; |
| 402 |
yyYear = $1 / 10000; |
| 403 |
yyMonth = ($1 % 10000)/100; |
| 404 |
yyDay = $1 % 100; |
| 405 |
yyHour = $3; |
| 406 |
yyMinutes = $5; |
| 407 |
yySeconds = $7; |
| 408 |
} |
| 409 |
| tISOBASE tISOBASE { |
| 410 |
yyYear = $1 / 10000; |
| 411 |
yyMonth = ($1 % 10000)/100; |
| 412 |
yyDay = $1 % 100; |
| 413 |
yyHour = $2 / 10000; |
| 414 |
yyMinutes = ($2 % 10000)/100; |
| 415 |
yySeconds = $2 % 100; |
| 416 |
} |
| 417 |
; |
| 418 |
|
| 419 |
trek : tSTARDATE tUNUMBER '.' tUNUMBER { |
| 420 |
/* |
| 421 |
* Offset computed year by -377 so that the returned years will be |
| 422 |
* in a range accessible with a 32 bit clock seconds value. |
| 423 |
*/ |
| 424 |
|
| 425 |
yyYear = $2/1000 + 2323 - 377; |
| 426 |
yyDay = 1; |
| 427 |
yyMonth = 1; |
| 428 |
yyRelDay += (($2%1000)*(365 + IsLeapYear(yyYear)))/1000; |
| 429 |
yyRelSeconds += $4 * (Tcl_WideInt)(144 * 60); |
| 430 |
} |
| 431 |
; |
| 432 |
|
| 433 |
relspec : relunits tAGO { |
| 434 |
yyRelSeconds *= -1; |
| 435 |
yyRelMonth *= -1; |
| 436 |
yyRelDay *= -1; |
| 437 |
} |
| 438 |
| relunits |
| 439 |
; |
| 440 |
|
| 441 |
relunits : sign tUNUMBER unit { |
| 442 |
*yyRelPointer += $1 * $2 * $3; |
| 443 |
} |
| 444 |
| tUNUMBER unit { |
| 445 |
*yyRelPointer += $1 * $2; |
| 446 |
} |
| 447 |
| tNEXT unit { |
| 448 |
*yyRelPointer += $2; |
| 449 |
} |
| 450 |
| tNEXT tUNUMBER unit { |
| 451 |
*yyRelPointer += $2 * $3; |
| 452 |
} |
| 453 |
| unit { |
| 454 |
*yyRelPointer += $1; |
| 455 |
} |
| 456 |
; |
| 457 |
|
| 458 |
sign : '-' { |
| 459 |
$$ = -1; |
| 460 |
} |
| 461 |
| '+' { |
| 462 |
$$ = 1; |
| 463 |
} |
| 464 |
; |
| 465 |
|
| 466 |
unit : tSEC_UNIT { |
| 467 |
$$ = $1; |
| 468 |
yyRelPointer = &yyRelSeconds; |
| 469 |
} |
| 470 |
| tDAY_UNIT { |
| 471 |
$$ = $1; |
| 472 |
yyRelPointer = &yyRelDay; |
| 473 |
} |
| 474 |
| tMONTH_UNIT { |
| 475 |
$$ = $1; |
| 476 |
yyRelPointer = &yyRelMonth; |
| 477 |
} |
| 478 |
; |
| 479 |
|
| 480 |
number : tUNUMBER { |
| 481 |
if (yyHaveTime && yyHaveDate && !yyHaveRel) { |
| 482 |
yyYear = $1; |
| 483 |
} else { |
| 484 |
yyHaveTime++; |
| 485 |
if (yyDigitCount <= 2) { |
| 486 |
yyHour = $1; |
| 487 |
yyMinutes = 0; |
| 488 |
} else { |
| 489 |
yyHour = $1 / 100; |
| 490 |
yyMinutes = $1 % 100; |
| 491 |
} |
| 492 |
yySeconds = 0; |
| 493 |
yyMeridian = MER24; |
| 494 |
} |
| 495 |
} |
| 496 |
; |
| 497 |
|
| 498 |
o_merid : /* NULL */ { |
| 499 |
$$ = MER24; |
| 500 |
} |
| 501 |
| tMERIDIAN { |
| 502 |
$$ = $1; |
| 503 |
} |
| 504 |
; |
| 505 |
|
| 506 |
%% |
| 507 |
/* |
| 508 |
* Month and day table. |
| 509 |
*/ |
| 510 |
|
| 511 |
static const TABLE MonthDayTable[] = { |
| 512 |
{ "january", tMONTH, 1 }, |
| 513 |
{ "february", tMONTH, 2 }, |
| 514 |
{ "march", tMONTH, 3 }, |
| 515 |
{ "april", tMONTH, 4 }, |
| 516 |
{ "may", tMONTH, 5 }, |
| 517 |
{ "june", tMONTH, 6 }, |
| 518 |
{ "july", tMONTH, 7 }, |
| 519 |
{ "august", tMONTH, 8 }, |
| 520 |
{ "september", tMONTH, 9 }, |
| 521 |
{ "sept", tMONTH, 9 }, |
| 522 |
{ "october", tMONTH, 10 }, |
| 523 |
{ "november", tMONTH, 11 }, |
| 524 |
{ "december", tMONTH, 12 }, |
| 525 |
{ "sunday", tDAY, 0 }, |
| 526 |
{ "monday", tDAY, 1 }, |
| 527 |
{ "tuesday", tDAY, 2 }, |
| 528 |
{ "tues", tDAY, 2 }, |
| 529 |
{ "wednesday", tDAY, 3 }, |
| 530 |
{ "wednes", tDAY, 3 }, |
| 531 |
{ "thursday", tDAY, 4 }, |
| 532 |
{ "thur", tDAY, 4 }, |
| 533 |
{ "thurs", tDAY, 4 }, |
| 534 |
{ "friday", tDAY, 5 }, |
| 535 |
{ "saturday", tDAY, 6 }, |
| 536 |
{ NULL, 0, 0 } |
| 537 |
}; |
| 538 |
|
| 539 |
/* |
| 540 |
* Time units table. |
| 541 |
*/ |
| 542 |
|
| 543 |
static const TABLE UnitsTable[] = { |
| 544 |
{ "year", tMONTH_UNIT, 12 }, |
| 545 |
{ "month", tMONTH_UNIT, 1 }, |
| 546 |
{ "fortnight", tDAY_UNIT, 14 }, |
| 547 |
{ "week", tDAY_UNIT, 7 }, |
| 548 |
{ "day", tDAY_UNIT, 1 }, |
| 549 |
{ "hour", tSEC_UNIT, 60 * 60 }, |
| 550 |
{ "minute", tSEC_UNIT, 60 }, |
| 551 |
{ "min", tSEC_UNIT, 60 }, |
| 552 |
{ "second", tSEC_UNIT, 1 }, |
| 553 |
{ "sec", tSEC_UNIT, 1 }, |
| 554 |
{ NULL, 0, 0 } |
| 555 |
}; |
| 556 |
|
| 557 |
/* |
| 558 |
* Assorted relative-time words. |
| 559 |
*/ |
| 560 |
|
| 561 |
static const TABLE OtherTable[] = { |
| 562 |
{ "tomorrow", tDAY_UNIT, 1 }, |
| 563 |
{ "yesterday", tDAY_UNIT, -1 }, |
| 564 |
{ "today", tDAY_UNIT, 0 }, |
| 565 |
{ "now", tSEC_UNIT, 0 }, |
| 566 |
{ "last", tUNUMBER, -1 }, |
| 567 |
{ "this", tSEC_UNIT, 0 }, |
| 568 |
{ "next", tNEXT, 1 }, |
| 569 |
{ "ago", tAGO, 1 }, |
| 570 |
{ "epoch", tEPOCH, 0 }, |
| 571 |
{ "stardate", tSTARDATE, 0 }, |
| 572 |
{ NULL, 0, 0 } |
| 573 |
}; |
| 574 |
|
| 575 |
/* |
| 576 |
* The timezone table. (Note: This table was modified to not use any floating |
| 577 |
* point constants to work around an SGI compiler bug). |
| 578 |
*/ |
| 579 |
|
| 580 |
static const TABLE TimezoneTable[] = { |
| 581 |
{ "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ |
| 582 |
{ "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ |
| 583 |
{ "utc", tZONE, HOUR( 0) }, |
| 584 |
{ "uct", tZONE, HOUR( 0) }, /* Universal Coordinated Time */ |
| 585 |
{ "wet", tZONE, HOUR( 0) }, /* Western European */ |
| 586 |
{ "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ |
| 587 |
{ "wat", tZONE, HOUR( 1) }, /* West Africa */ |
| 588 |
{ "at", tZONE, HOUR( 2) }, /* Azores */ |
| 589 |
#if 0 |
| 590 |
/* For completeness. BST is also British Summer, and GST is |
| 591 |
* also Guam Standard. */ |
| 592 |
{ "bst", tZONE, HOUR( 3) }, /* Brazil Standard */ |
| 593 |
{ "gst", tZONE, HOUR( 3) }, /* Greenland Standard */ |
| 594 |
#endif |
| 595 |
{ "nft", tZONE, HOUR( 7/2) }, /* Newfoundland */ |
| 596 |
{ "nst", tZONE, HOUR( 7/2) }, /* Newfoundland Standard */ |
| 597 |
{ "ndt", tDAYZONE, HOUR( 7/2) }, /* Newfoundland Daylight */ |
| 598 |
{ "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */ |
| 599 |
{ "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */ |
| 600 |
{ "est", tZONE, HOUR( 5) }, /* Eastern Standard */ |
| 601 |
{ "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */ |
| 602 |
{ "cst", tZONE, HOUR( 6) }, /* Central Standard */ |
| 603 |
{ "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */ |
| 604 |
{ "mst", tZONE, HOUR( 7) }, /* Mountain Standard */ |
| 605 |
{ "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */ |
| 606 |
{ "pst", tZONE, HOUR( 8) }, /* Pacific Standard */ |
| 607 |
{ "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */ |
| 608 |
{ "yst", tZONE, HOUR( 9) }, /* Yukon Standard */ |
| 609 |
{ "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */ |
| 610 |
{ "akst", tZONE, HOUR( 9) }, /* Alaska Standard */ |
| 611 |
{ "akdt", tDAYZONE, HOUR( 9) }, /* Alaska Daylight */ |
| 612 |
{ "hst", tZONE, HOUR(10) }, /* Hawaii Standard */ |
| 613 |
{ "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */ |
| 614 |
{ "cat", tZONE, HOUR(10) }, /* Central Alaska */ |
| 615 |
{ "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */ |
| 616 |
{ "nt", tZONE, HOUR(11) }, /* Nome */ |
| 617 |
{ "idlw", tZONE, HOUR(12) }, /* International Date Line West */ |
| 618 |
{ "cet", tZONE, -HOUR( 1) }, /* Central European */ |
| 619 |
{ "cest", tDAYZONE, -HOUR( 1) }, /* Central European Summer */ |
| 620 |
{ "met", tZONE, -HOUR( 1) }, /* Middle European */ |
| 621 |
{ "mewt", tZONE, -HOUR( 1) }, /* Middle European Winter */ |
| 622 |
{ "mest", tDAYZONE, -HOUR( 1) }, /* Middle European Summer */ |
| 623 |
{ "swt", tZONE, -HOUR( 1) }, /* Swedish Winter */ |
| 624 |
{ "sst", tDAYZONE, -HOUR( 1) }, /* Swedish Summer */ |
| 625 |
{ "fwt", tZONE, -HOUR( 1) }, /* French Winter */ |
| 626 |
{ "fst", tDAYZONE, -HOUR( 1) }, /* French Summer */ |
| 627 |
{ "eet", tZONE, -HOUR( 2) }, /* Eastern Europe, USSR Zone 1 */ |
| 628 |
{ "bt", tZONE, -HOUR( 3) }, /* Baghdad, USSR Zone 2 */ |
| 629 |
{ "it", tZONE, -HOUR( 7/2) }, /* Iran */ |
| 630 |
{ "zp4", tZONE, -HOUR( 4) }, /* USSR Zone 3 */ |
| 631 |
{ "zp5", tZONE, -HOUR( 5) }, /* USSR Zone 4 */ |
| 632 |
{ "ist", tZONE, -HOUR(11/2) }, /* Indian Standard */ |
| 633 |
{ "zp6", tZONE, -HOUR( 6) }, /* USSR Zone 5 */ |
| 634 |
#if 0 |
| 635 |
/* For completeness. NST is also Newfoundland Standard, and SST is |
| 636 |
* also Swedish Summer. */ |
| 637 |
{ "nst", tZONE, -HOUR(13/2) }, /* North Sumatra */ |
| 638 |
{ "sst", tZONE, -HOUR( 7) }, /* South Sumatra, USSR Zone 6 */ |
| 639 |
#endif /* 0 */ |
| 640 |
{ "wast", tZONE, -HOUR( 7) }, /* West Australian Standard */ |
| 641 |
{ "wadt", tDAYZONE, -HOUR( 7) }, /* West Australian Daylight */ |
| 642 |
{ "jt", tZONE, -HOUR(15/2) }, /* Java (3pm in Cronusland!) */ |
| 643 |
{ "cct", tZONE, -HOUR( 8) }, /* China Coast, USSR Zone 7 */ |
| 644 |
{ "jst", tZONE, -HOUR( 9) }, /* Japan Standard, USSR Zone 8 */ |
| 645 |
{ "jdt", tDAYZONE, -HOUR( 9) }, /* Japan Daylight */ |
| 646 |
{ "kst", tZONE, -HOUR( 9) }, /* Korea Standard */ |
| 647 |
{ "kdt", tDAYZONE, -HOUR( 9) }, /* Korea Daylight */ |
| 648 |
{ "cast", tZONE, -HOUR(19/2) }, /* Central Australian Standard */ |
| 649 |
{ "cadt", tDAYZONE, -HOUR(19/2) }, /* Central Australian Daylight */ |
| 650 |
{ "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */ |
| 651 |
{ "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */ |
| 652 |
{ "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */ |
| 653 |
{ "nzt", tZONE, -HOUR(12) }, /* New Zealand */ |
| 654 |
{ "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ |
| 655 |
{ "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ |
| 656 |
{ "idle", tZONE, -HOUR(12) }, /* International Date Line East */ |
| 657 |
/* ADDED BY Marco Nijdam */ |
| 658 |
{ "dst", tDST, HOUR( 0) }, /* DST on (hour is ignored) */ |
| 659 |
/* End ADDED */ |
| 660 |
{ NULL, 0, 0 } |
| 661 |
}; |
| 662 |
|
| 663 |
/* |
| 664 |
* Military timezone table. |
| 665 |
*/ |
| 666 |
|
| 667 |
static const TABLE MilitaryTable[] = { |
| 668 |
{ "a", tZONE, -HOUR( 1) + HOUR(100) }, |
| 669 |
{ "b", tZONE, -HOUR( 2) + HOUR(100) }, |
| 670 |
{ "c", tZONE, -HOUR( 3) + HOUR(100) }, |
| 671 |
{ "d", tZONE, -HOUR( 4) + HOUR(100) }, |
| 672 |
{ "e", tZONE, -HOUR( 5) + HOUR(100) }, |
| 673 |
{ "f", tZONE, -HOUR( 6) + HOUR(100) }, |
| 674 |
{ "g", tZONE, -HOUR( 7) + HOUR(100) }, |
| 675 |
{ "h", tZONE, -HOUR( 8) + HOUR(100) }, |
| 676 |
{ "i", tZONE, -HOUR( 9) + HOUR(100) }, |
| 677 |
{ "k", tZONE, -HOUR(10) + HOUR(100) }, |
| 678 |
{ "l", tZONE, -HOUR(11) + HOUR(100) }, |
| 679 |
{ "m", tZONE, -HOUR(12) + HOUR(100) }, |
| 680 |
{ "n", tZONE, HOUR( 1) + HOUR(100) }, |
| 681 |
{ "o", tZONE, HOUR( 2) + HOUR(100) }, |
| 682 |
{ "p", tZONE, HOUR( 3) + HOUR(100) }, |
| 683 |
{ "q", tZONE, HOUR( 4) + HOUR(100) }, |
| 684 |
{ "r", tZONE, HOUR( 5) + HOUR(100) }, |
| 685 |
{ "s", tZONE, HOUR( 6) + HOUR(100) }, |
| 686 |
{ "t", tZONE, HOUR( 7) + HOUR(100) }, |
| 687 |
{ "u", tZONE, HOUR( 8) + HOUR(100) }, |
| 688 |
{ "v", tZONE, HOUR( 9) + HOUR(100) }, |
| 689 |
{ "w", tZONE, HOUR( 10) + HOUR(100) }, |
| 690 |
{ "x", tZONE, HOUR( 11) + HOUR(100) }, |
| 691 |
{ "y", tZONE, HOUR( 12) + HOUR(100) }, |
| 692 |
{ "z", tZONE, HOUR( 0) + HOUR(100) }, |
| 693 |
{ NULL, 0, 0 } |
| 694 |
}; |
| 695 |
|
| 696 |
/* |
| 697 |
* Dump error messages in the bit bucket. |
| 698 |
*/ |
| 699 |
|
| 700 |
static void |
| 701 |
TclDateerror( |
| 702 |
YYLTYPE* location, |
| 703 |
DateInfo* infoPtr, |
| 704 |
const char *s) |
| 705 |
{ |
| 706 |
Tcl_Obj* t; |
| 707 |
Tcl_AppendToObj(infoPtr->messages, infoPtr->separatrix, -1); |
| 708 |
Tcl_AppendToObj(infoPtr->messages, s, -1); |
| 709 |
Tcl_AppendToObj(infoPtr->messages, " (characters ", -1); |
| 710 |
TclNewIntObj(t, location->first_column); |
| 711 |
Tcl_IncrRefCount(t); |
| 712 |
Tcl_AppendObjToObj(infoPtr->messages, t); |
| 713 |
Tcl_DecrRefCount(t); |
| 714 |
Tcl_AppendToObj(infoPtr->messages, "-", -1); |
| 715 |
TclNewIntObj(t, location->last_column); |
| 716 |
Tcl_IncrRefCount(t); |
| 717 |
Tcl_AppendObjToObj(infoPtr->messages, t); |
| 718 |
Tcl_DecrRefCount(t); |
| 719 |
Tcl_AppendToObj(infoPtr->messages, ")", -1); |
| 720 |
infoPtr->separatrix = "\n"; |
| 721 |
} |
| 722 |
|
| 723 |
static time_t |
| 724 |
ToSeconds( |
| 725 |
time_t Hours, |
| 726 |
time_t Minutes, |
| 727 |
time_t Seconds, |
| 728 |
MERIDIAN Meridian) |
| 729 |
{ |
| 730 |
switch (Meridian) { |
| 731 |
case MER24: |
| 732 |
return (Hours * 60 + Minutes) * 60 + Seconds; |
| 733 |
case MERam: |
| 734 |
return ((Hours % 12) * 60 + Minutes) * 60 + Seconds; |
| 735 |
case MERpm: |
| 736 |
return (((Hours % 12) + 12) * 60 + Minutes) * 60 + Seconds; |
| 737 |
} |
| 738 |
return -1; /* Should never be reached */ |
| 739 |
} |
| 740 |
|
| 741 |
static int |
| 742 |
LookupWord( |
| 743 |
YYSTYPE* yylvalPtr, |
| 744 |
char *buff) |
| 745 |
{ |
| 746 |
char *p; |
| 747 |
char *q; |
| 748 |
const TABLE *tp; |
| 749 |
int i, abbrev; |
| 750 |
|
| 751 |
/* |
| 752 |
* Make it lowercase. |
| 753 |
*/ |
| 754 |
|
| 755 |
Tcl_UtfToLower(buff); |
| 756 |
|
| 757 |
if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) { |
| 758 |
yylvalPtr->Meridian = MERam; |
| 759 |
return tMERIDIAN; |
| 760 |
} |
| 761 |
if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) { |
| 762 |
yylvalPtr->Meridian = MERpm; |
| 763 |
return tMERIDIAN; |
| 764 |
} |
| 765 |
|
| 766 |
/* |
| 767 |
* See if we have an abbreviation for a month. |
| 768 |
*/ |
| 769 |
|
| 770 |
if (strlen(buff) == 3) { |
| 771 |
abbrev = 1; |
| 772 |
} else if (strlen(buff) == 4 && buff[3] == '.') { |
| 773 |
abbrev = 1; |
| 774 |
buff[3] = '\0'; |
| 775 |
} else { |
| 776 |
abbrev = 0; |
| 777 |
} |
| 778 |
|
| 779 |
for (tp = MonthDayTable; tp->name; tp++) { |
| 780 |
if (abbrev) { |
| 781 |
if (strncmp(buff, tp->name, 3) == 0) { |
| 782 |
yylvalPtr->Number = tp->value; |
| 783 |
return tp->type; |
| 784 |
} |
| 785 |
} else if (strcmp(buff, tp->name) == 0) { |
| 786 |
yylvalPtr->Number = tp->value; |
| 787 |
return tp->type; |
| 788 |
} |
| 789 |
} |
| 790 |
|
| 791 |
for (tp = TimezoneTable; tp->name; tp++) { |
| 792 |
if (strcmp(buff, tp->name) == 0) { |
| 793 |
yylvalPtr->Number = tp->value; |
| 794 |
return tp->type; |
| 795 |
} |
| 796 |
} |
| 797 |
|
| 798 |
for (tp = UnitsTable; tp->name; tp++) { |
| 799 |
if (strcmp(buff, tp->name) == 0) { |
| 800 |
yylvalPtr->Number = tp->value; |
| 801 |
return tp->type; |
| 802 |
} |
| 803 |
} |
| 804 |
|
| 805 |
/* |
| 806 |
* Strip off any plural and try the units table again. |
| 807 |
*/ |
| 808 |
|
| 809 |
i = strlen(buff) - 1; |
| 810 |
if (i > 0 && buff[i] == 's') { |
| 811 |
buff[i] = '\0'; |
| 812 |
for (tp = UnitsTable; tp->name; tp++) { |
| 813 |
if (strcmp(buff, tp->name) == 0) { |
| 814 |
yylvalPtr->Number = tp->value; |
| 815 |
return tp->type; |
| 816 |
} |
| 817 |
} |
| 818 |
} |
| 819 |
|
| 820 |
for (tp = OtherTable; tp->name; tp++) { |
| 821 |
if (strcmp(buff, tp->name) == 0) { |
| 822 |
yylvalPtr->Number = tp->value; |
| 823 |
return tp->type; |
| 824 |
} |
| 825 |
} |
| 826 |
|
| 827 |
/* |
| 828 |
* Military timezones. |
| 829 |
*/ |
| 830 |
|
| 831 |
if (buff[1] == '\0' && !(*buff & 0x80) |
| 832 |
&& isalpha(UCHAR(*buff))) { /* INTL: ISO only */ |
| 833 |
for (tp = MilitaryTable; tp->name; tp++) { |
| 834 |
if (strcmp(buff, tp->name) == 0) { |
| 835 |
yylvalPtr->Number = tp->value; |
| 836 |
return tp->type; |
| 837 |
} |
| 838 |
} |
| 839 |
} |
| 840 |
|
| 841 |
/* |
| 842 |
* Drop out any periods and try the timezone table again. |
| 843 |
*/ |
| 844 |
|
| 845 |
for (i = 0, p = q = buff; *q; q++) { |
| 846 |
if (*q != '.') { |
| 847 |
*p++ = *q; |
| 848 |
} else { |
| 849 |
i++; |
| 850 |
} |
| 851 |
} |
| 852 |
*p = '\0'; |
| 853 |
if (i) { |
| 854 |
for (tp = TimezoneTable; tp->name; tp++) { |
| 855 |
if (strcmp(buff, tp->name) == 0) { |
| 856 |
yylvalPtr->Number = tp->value; |
| 857 |
return tp->type; |
| 858 |
} |
| 859 |
} |
| 860 |
} |
| 861 |
|
| 862 |
return tID; |
| 863 |
} |
| 864 |
|
| 865 |
static int |
| 866 |
TclDatelex( |
| 867 |
YYSTYPE* yylvalPtr, |
| 868 |
YYLTYPE* location, |
| 869 |
DateInfo *info) |
| 870 |
{ |
| 871 |
char c; |
| 872 |
char *p; |
| 873 |
char buff[20]; |
| 874 |
int Count; |
| 875 |
|
| 876 |
location->first_column = yyInput - info->dateStart; |
| 877 |
for ( ; ; ) { |
| 878 |
while (TclIsSpaceProcM(*yyInput)) { |
| 879 |
yyInput++; |
| 880 |
} |
| 881 |
|
| 882 |
if (isdigit(UCHAR(c = *yyInput))) { /* INTL: digit */ |
| 883 |
/* |
| 884 |
* Convert the string into a number; count the number of digits. |
| 885 |
*/ |
| 886 |
|
| 887 |
Count = 0; |
| 888 |
for (yylvalPtr->Number = 0; |
| 889 |
isdigit(UCHAR(c = *yyInput++)); ) { /* INTL: digit */ |
| 890 |
yylvalPtr->Number = 10 * yylvalPtr->Number + c - '0'; |
| 891 |
Count++; |
| 892 |
} |
| 893 |
yyInput--; |
| 894 |
yyDigitCount = Count; |
| 895 |
|
| 896 |
/* |
| 897 |
* A number with 6 or more digits is considered an ISO 8601 base. |
| 898 |
*/ |
| 899 |
|
| 900 |
if (Count >= 6) { |
| 901 |
location->last_column = yyInput - info->dateStart - 1; |
| 902 |
return tISOBASE; |
| 903 |
} else { |
| 904 |
location->last_column = yyInput - info->dateStart - 1; |
| 905 |
return tUNUMBER; |
| 906 |
} |
| 907 |
} |
| 908 |
if (!(c & 0x80) && isalpha(UCHAR(c))) { /* INTL: ISO only. */ |
| 909 |
for (p = buff; isalpha(UCHAR(c = *yyInput++)) /* INTL: ISO only. */ |
| 910 |
|| c == '.'; ) { |
| 911 |
if (p < &buff[sizeof buff - 1]) { |
| 912 |
*p++ = c; |
| 913 |
} |
| 914 |
} |
| 915 |
*p = '\0'; |
| 916 |
yyInput--; |
| 917 |
location->last_column = yyInput - info->dateStart - 1; |
| 918 |
return LookupWord(yylvalPtr, buff); |
| 919 |
} |
| 920 |
if (c != '(') { |
| 921 |
location->last_column = yyInput - info->dateStart; |
| 922 |
return *yyInput++; |
| 923 |
} |
| 924 |
Count = 0; |
| 925 |
do { |
| 926 |
c = *yyInput++; |
| 927 |
if (c == '\0') { |
| 928 |
location->last_column = yyInput - info->dateStart - 1; |
| 929 |
return c; |
| 930 |
} else if (c == '(') { |
| 931 |
Count++; |
| 932 |
} else if (c == ')') { |
| 933 |
Count--; |
| 934 |
} |
| 935 |
} while (Count > 0); |
| 936 |
} |
| 937 |
} |
| 938 |
|
| 939 |
int |
| 940 |
TclClockOldscanObjCmd( |
| 941 |
void *dummy, /* Unused */ |
| 942 |
Tcl_Interp *interp, /* Tcl interpreter */ |
| 943 |
int objc, /* Count of parameters */ |
| 944 |
Tcl_Obj *const *objv) /* Parameters */ |
| 945 |
{ |
| 946 |
Tcl_Obj *result, *resultElement; |
| 947 |
int yr, mo, da; |
| 948 |
DateInfo dateInfo; |
| 949 |
DateInfo* info = &dateInfo; |
| 950 |
int status; |
| 951 |
(void)dummy; |
| 952 |
|
| 953 |
if (objc != 5) { |
| 954 |
Tcl_WrongNumArgs(interp, 1, objv, |
| 955 |
"stringToParse baseYear baseMonth baseDay" ); |
| 956 |
return TCL_ERROR; |
| 957 |
} |
| 958 |
|
| 959 |
yyInput = TclGetString(objv[1]); |
| 960 |
dateInfo.dateStart = yyInput; |
| 961 |
|
| 962 |
yyHaveDate = 0; |
| 963 |
if (Tcl_GetIntFromObj(interp, objv[2], &yr) != TCL_OK |
| 964 |
|| Tcl_GetIntFromObj(interp, objv[3], &mo) != TCL_OK |
| 965 |
|| Tcl_GetIntFromObj(interp, objv[4], &da) != TCL_OK) { |
| 966 |
return TCL_ERROR; |
| 967 |
} |
| 968 |
yyYear = yr; yyMonth = mo; yyDay = da; |
| 969 |
|
| 970 |
yyHaveTime = 0; |
| 971 |
yyHour = 0; yyMinutes = 0; yySeconds = 0; yyMeridian = MER24; |
| 972 |
|
| 973 |
yyHaveZone = 0; |
| 974 |
yyTimezone = 0; yyDSTmode = DSTmaybe; |
| 975 |
|
| 976 |
yyHaveOrdinalMonth = 0; |
| 977 |
yyMonthOrdinal = 0; |
| 978 |
|
| 979 |
yyHaveDay = 0; |
| 980 |
yyDayOrdinal = 0; yyDayNumber = 0; |
| 981 |
|
| 982 |
yyHaveRel = 0; |
| 983 |
yyRelMonth = 0; yyRelDay = 0; yyRelSeconds = 0; yyRelPointer = NULL; |
| 984 |
|
| 985 |
TclNewObj(dateInfo.messages); |
| 986 |
dateInfo.separatrix = ""; |
| 987 |
Tcl_IncrRefCount(dateInfo.messages); |
| 988 |
|
| 989 |
status = yyparse(&dateInfo); |
| 990 |
if (status == 1) { |
| 991 |
Tcl_SetObjResult(interp, dateInfo.messages); |
| 992 |
Tcl_DecrRefCount(dateInfo.messages); |
| 993 |
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "PARSE", (char *)NULL); |
| 994 |
return TCL_ERROR; |
| 995 |
} else if (status == 2) { |
| 996 |
Tcl_SetObjResult(interp, Tcl_NewStringObj("memory exhausted", -1)); |
| 997 |
Tcl_DecrRefCount(dateInfo.messages); |
| 998 |
Tcl_SetErrorCode(interp, "TCL", "MEMORY", (char *)NULL); |
| 999 |
return TCL_ERROR; |
| 1000 |
} else if (status != 0) { |
| 1001 |
Tcl_SetObjResult(interp, Tcl_NewStringObj("Unknown status returned " |
| 1002 |
"from date parser. Please " |
| 1003 |
"report this error as a " |
| 1004 |
"bug in Tcl.", -1)); |
| 1005 |
Tcl_DecrRefCount(dateInfo.messages); |
| 1006 |
Tcl_SetErrorCode(interp, "TCL", "BUG", (char *)NULL); |
| 1007 |
return TCL_ERROR; |
| 1008 |
} |
| 1009 |
Tcl_DecrRefCount(dateInfo.messages); |
| 1010 |
|
| 1011 |
if (yyHaveDate > 1) { |
| 1012 |
Tcl_SetObjResult(interp, |
| 1013 |
Tcl_NewStringObj("more than one date in string", -1)); |
| 1014 |
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", (char *)NULL); |
| 1015 |
return TCL_ERROR; |
| 1016 |
} |
| 1017 |
if (yyHaveTime > 1) { |
| 1018 |
Tcl_SetObjResult(interp, |
| 1019 |
Tcl_NewStringObj("more than one time of day in string", -1)); |
| 1020 |
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", (char *)NULL); |
| 1021 |
return TCL_ERROR; |
| 1022 |
} |
| 1023 |
if (yyHaveZone > 1) { |
| 1024 |
Tcl_SetObjResult(interp, |
| 1025 |
Tcl_NewStringObj("more than one time zone in string", -1)); |
| 1026 |
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", (char *)NULL); |
| 1027 |
return TCL_ERROR; |
| 1028 |
} |
| 1029 |
if (yyHaveDay > 1) { |
| 1030 |
Tcl_SetObjResult(interp, |
| 1031 |
Tcl_NewStringObj("more than one weekday in string", -1)); |
| 1032 |
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", (char *)NULL); |
| 1033 |
return TCL_ERROR; |
| 1034 |
} |
| 1035 |
if (yyHaveOrdinalMonth > 1) { |
| 1036 |
Tcl_SetObjResult(interp, |
| 1037 |
Tcl_NewStringObj("more than one ordinal month in string", -1)); |
| 1038 |
Tcl_SetErrorCode(interp, "TCL", "VALUE", "DATE", "MULTIPLE", (char *)NULL); |
| 1039 |
return TCL_ERROR; |
| 1040 |
} |
| 1041 |
|
| 1042 |
TclNewObj(result); |
| 1043 |
TclNewObj(resultElement); |
| 1044 |
if (yyHaveDate) { |
| 1045 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1046 |
Tcl_NewIntObj((int) yyYear)); |
| 1047 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1048 |
Tcl_NewIntObj((int) yyMonth)); |
| 1049 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1050 |
Tcl_NewIntObj((int) yyDay)); |
| 1051 |
} |
| 1052 |
Tcl_ListObjAppendElement(interp, result, resultElement); |
| 1053 |
|
| 1054 |
if (yyHaveTime) { |
| 1055 |
Tcl_ListObjAppendElement(interp, result, Tcl_NewIntObj((int) |
| 1056 |
ToSeconds(yyHour, yyMinutes, yySeconds, (MERIDIAN)yyMeridian))); |
| 1057 |
} else { |
| 1058 |
Tcl_ListObjAppendElement(interp, result, Tcl_NewObj()); |
| 1059 |
} |
| 1060 |
|
| 1061 |
TclNewObj(resultElement); |
| 1062 |
if (yyHaveZone) { |
| 1063 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1064 |
Tcl_NewIntObj((int) -yyTimezone)); |
| 1065 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1066 |
Tcl_NewIntObj(1 - yyDSTmode)); |
| 1067 |
} |
| 1068 |
Tcl_ListObjAppendElement(interp, result, resultElement); |
| 1069 |
|
| 1070 |
TclNewObj(resultElement); |
| 1071 |
if (yyHaveRel) { |
| 1072 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1073 |
Tcl_NewIntObj((int) yyRelMonth)); |
| 1074 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1075 |
Tcl_NewIntObj((int) yyRelDay)); |
| 1076 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1077 |
Tcl_NewWideIntObj(yyRelSeconds)); |
| 1078 |
} |
| 1079 |
Tcl_ListObjAppendElement(interp, result, resultElement); |
| 1080 |
|
| 1081 |
TclNewObj(resultElement); |
| 1082 |
if (yyHaveDay && !yyHaveDate) { |
| 1083 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1084 |
Tcl_NewIntObj((int) yyDayOrdinal)); |
| 1085 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1086 |
Tcl_NewIntObj((int) yyDayNumber)); |
| 1087 |
} |
| 1088 |
Tcl_ListObjAppendElement(interp, result, resultElement); |
| 1089 |
|
| 1090 |
TclNewObj(resultElement); |
| 1091 |
if (yyHaveOrdinalMonth) { |
| 1092 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1093 |
Tcl_NewIntObj((int) yyMonthOrdinal)); |
| 1094 |
Tcl_ListObjAppendElement(interp, resultElement, |
| 1095 |
Tcl_NewIntObj((int) yyMonth)); |
| 1096 |
} |
| 1097 |
Tcl_ListObjAppendElement(interp, result, resultElement); |
| 1098 |
|
| 1099 |
Tcl_SetObjResult(interp, result); |
| 1100 |
return TCL_OK; |
| 1101 |
} |
| 1102 |
|
| 1103 |
/* |
| 1104 |
* Local Variables: |
| 1105 |
* mode: c |
| 1106 |
* c-basic-offset: 4 |
| 1107 |
* fill-column: 78 |
| 1108 |
* End: |
| 1109 |
*/ |