3 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
4 * Use is subject to license terms.
6 #pragma ident "%Z%%M% %I% %E% SMI"
8 /* $OrigRevision: 2.1 $
10 ** Originally written by Steven M. Bellovin <smb@research.att.com> while
11 ** at the University of North Carolina at Chapel Hill. Later tweaked by
12 ** a couple of people on Usenet. Completely overhauled by Rich $alz
13 ** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
14 ** send any email to Rich.
16 ** This grammar has eight shift/reduce conflicts.
18 ** This code is in the public domain and has no copyright.
20 /* SUPPRESS 287 on yaccpar_sccsid *//* Unusd static variable */
21 /* SUPPRESS 288 on yyerrlab *//* Label unused */
25 #include <sys/types.h>
28 time_t time
; /* Seconds since the epoch */
29 unsigned short millitm
; /* Field not used */
31 short dstflag
; /* Field not used */
41 #if !defined(lint) && !defined(SABER)
43 "$Header: /home/laramie/berliner/ws/backup/usr/src/cmd/backup/lib/getdate.y,v 1.5 1992/06/09 21:46:21 sam Exp $";
44 #endif /* !defined(lint) && !defined(SABER) */
48 #define HOURN(x) (x * 60)
49 #define SECSPERDAY (24L * 60L * 60L)
51 #define CHECK_TM(y) (((y) % 100) < 70 ? (y) + 2000 : (y) + 1900)
54 ** An entry in the lexical lookup table.
56 typedef
struct _TABLE
{
64 ** Daylight-savings mode: on, off, or not yet known.
66 typedef
enum _DSTMODE
{
67 DSTon
, DSToff
, DSTmaybe
71 ** Meridian: am, pm, or 24-hour style.
73 typedef
enum _MERIDIAN
{
79 ** Global variables. We could get rid of most of these by using a good
80 ** union as the yacc stack. (This routine was originally written before
81 ** yacc had the %union construct.) Maybe someday; right now we only use
82 ** the %union very rarely.
85 static DSTMODE yyDSTmode
;
86 static time_t yyDayOrdinal
;
87 static time_t yyDayNumber
;
88 static int yyHaveDate
;
91 static int yyHaveTime
;
92 static int yyHaveZone
;
93 static time_t yyTimezone
;
96 static time_t yyMinutes
;
97 static time_t yyMonth
;
98 static time_t yySeconds
;
100 static MERIDIAN yyMeridian
;
101 static time_t yyRelMonth
;
102 static time_t yyRelSeconds
;
104 static char *domainname
= "hsm_libdump"; /* for dgettext() */
106 #define yylex 1 /* suppress yacc's definition */
111 enum _MERIDIAN Meridian
;
114 %token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
115 %token tSEC_UNIT tSNUMBER tUNUMBER tZONE
117 %type
<Number
> tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT
118 %type
<Number
> tSEC_UNIT tSNUMBER tUNUMBER tZONE
119 %type
<Meridian
> tMERIDIAN o_merid
145 time
: tUNUMBER tMERIDIAN
{
151 | tUNUMBER
':' tUNUMBER o_merid
{
157 | tUNUMBER
':' tUNUMBER tSNUMBER
{
162 yyTimezone
= - ($4 %
100 + ($4 / 100) * 60);
164 | tUNUMBER
':' tUNUMBER
':' tUNUMBER o_merid
{
170 | tUNUMBER
':' tUNUMBER
':' tUNUMBER tSNUMBER
{
176 yyTimezone
= - ($6 %
100 + ($6 / 100) * 60);
204 date
: tUNUMBER
'/' tUNUMBER
{
208 | tUNUMBER
'/' tUNUMBER
'/' tUNUMBER
{
217 | tMONTH tUNUMBER
',' tUNUMBER
{
226 | tUNUMBER tMONTH tUNUMBER
{
234 yyRelSeconds
= -yyRelSeconds
;
235 yyRelMonth
= -yyRelMonth
;
240 relunit
: tUNUMBER tMINUTE_UNIT
{
241 yyRelSeconds
+= $1 * $2 * 60L;
243 | tSNUMBER tMINUTE_UNIT
{
244 yyRelSeconds
+= $1 * $2 * 60L;
247 yyRelSeconds
+= $1 * 60L;
249 | tSNUMBER tSEC_UNIT
{
252 | tUNUMBER tSEC_UNIT
{
258 | tSNUMBER tMONTH_UNIT
{
259 yyRelMonth
+= $1 * $2;
261 | tUNUMBER tMONTH_UNIT
{
262 yyRelMonth
+= $1 * $2;
270 if
(yyHaveTime
&& yyHaveDate
&& !yyHaveRel
)
280 yyMinutes
= $1 %
100;
288 o_merid
: /* NULL */ {
298 /* Month and day table. */
299 static TABLE MonthDayTable
[] = {
300 { "january", tMONTH
, 1 },
301 { "february", tMONTH
, 2 },
302 { "march", tMONTH
, 3 },
303 { "april", tMONTH
, 4 },
304 { "may", tMONTH
, 5 },
305 { "june", tMONTH
, 6 },
306 { "july", tMONTH
, 7 },
307 { "august", tMONTH
, 8 },
308 { "september", tMONTH
, 9 },
309 { "sept", tMONTH
, 9 },
310 { "october", tMONTH
, 10 },
311 { "november", tMONTH
, 11 },
312 { "december", tMONTH
, 12 },
313 { "sunday", tDAY
, 0 },
314 { "monday", tDAY
, 1 },
315 { "tuesday", tDAY
, 2 },
317 { "wednesday", tDAY
, 3 },
318 { "wednes", tDAY
, 3 },
319 { "thursday", tDAY
, 4 },
321 { "thurs", tDAY
, 4 },
322 { "friday", tDAY
, 5 },
323 { "saturday", tDAY
, 6 },
327 /* Time units table. */
328 static TABLE UnitsTable
[] = {
329 { "year", tMONTH_UNIT
, 12 },
330 { "month", tMONTH_UNIT
, 1 },
331 { "fortnight", tMINUTE_UNIT
, 14 * 24 * 60 },
332 { "week", tMINUTE_UNIT
, 7 * 24 * 60 },
333 { "day", tMINUTE_UNIT
, 1 * 24 * 60 },
334 { "hour", tMINUTE_UNIT
, 60 },
335 { "minute", tMINUTE_UNIT
, 1 },
336 { "min", tMINUTE_UNIT
, 1 },
337 { "second", tSEC_UNIT
, 1 },
338 { "sec", tSEC_UNIT
, 1 },
342 /* Assorted relative-time words. */
343 static TABLE OtherTable
[] = {
344 { "tomorrow", tMINUTE_UNIT
, 1 * 24 * 60 },
345 { "yesterday", tMINUTE_UNIT
, -1 * 24 * 60 },
346 { "today", tMINUTE_UNIT
, 0 },
347 { "now", tMINUTE_UNIT
, 0 },
348 { "last", tUNUMBER
, -1 },
349 { "this", tMINUTE_UNIT
, 0 },
350 { "next", tUNUMBER
, 2 },
351 { "first", tUNUMBER
, 1 },
352 /* { "second", tUNUMBER, 2 }, */
353 { "third", tUNUMBER
, 3 },
354 { "fourth", tUNUMBER
, 4 },
355 { "fifth", tUNUMBER
, 5 },
356 { "sixth", tUNUMBER
, 6 },
357 { "seventh", tUNUMBER
, 7 },
358 { "eighth", tUNUMBER
, 8 },
359 { "ninth", tUNUMBER
, 9 },
360 { "tenth", tUNUMBER
, 10 },
361 { "eleventh", tUNUMBER
, 11 },
362 { "twelfth", tUNUMBER
, 12 },
367 /* The timezone table. */
368 static TABLE TimezoneTable
[] = {
369 { "gmt", tZONE
, HOURN
( 0) }, /* Greenwich Mean */
370 { "ut", tZONE
, HOURN
( 0) }, /* Universal (Coordinated) */
371 { "utc", tZONE
, HOURN
( 0) },
372 { "wet", tZONE
, HOURN
( 0) }, /* Western European */
373 { "bst", tDAYZONE
, HOURN
( 0) }, /* British Summer */
374 { "wat", tZONE
, HOURN
( 1) }, /* West Africa */
375 { "at", tZONE
, HOURN
( 2) }, /* Azores */
377 /* For completeness. BST is also British Summer, and GST is
378 * also Guam Standard. */
379 { "bst", tZONE
, HOURN
( 3) }, /* Brazil Standard */
380 { "gst", tZONE
, HOURN
( 3) }, /* Greenland Standard */
382 { "nft", tZONE
, HOURN
(3.5) }, /* Newfoundland */
383 { "nst", tZONE
, HOURN
(3.5) }, /* Newfoundland Standard */
384 { "ndt", tDAYZONE
, HOURN
(3.5) }, /* Newfoundland Daylight */
385 { "ast", tZONE
, HOURN
( 4) }, /* Atlantic Standard */
386 { "adt", tDAYZONE
, HOURN
( 4) }, /* Atlantic Daylight */
387 { "est", tZONE
, HOURN
( 5) }, /* Eastern Standard */
388 { "edt", tDAYZONE
, HOURN
( 5) }, /* Eastern Daylight */
389 { "cst", tZONE
, HOURN
( 6) }, /* Central Standard */
390 { "cdt", tDAYZONE
, HOURN
( 6) }, /* Central Daylight */
391 { "mst", tZONE
, HOURN
( 7) }, /* Mountain Standard */
392 { "mdt", tDAYZONE
, HOURN
( 7) }, /* Mountain Daylight */
393 { "pst", tZONE
, HOURN
( 8) }, /* Pacific Standard */
394 { "pdt", tDAYZONE
, HOURN
( 8) }, /* Pacific Daylight */
395 { "yst", tZONE
, HOURN
( 9) }, /* Yukon Standard */
396 { "ydt", tDAYZONE
, HOURN
( 9) }, /* Yukon Daylight */
397 { "hst", tZONE
, HOURN
(10) }, /* Hawaii Standard */
398 { "hdt", tDAYZONE
, HOURN
(10) }, /* Hawaii Daylight */
399 { "cat", tZONE
, HOURN
(10) }, /* Central Alaska */
400 { "ahst", tZONE
, HOURN
(10) }, /* Alaska-Hawaii Standard */
401 { "nt", tZONE
, HOURN
(11) }, /* Nome */
402 { "idlw", tZONE
, HOURN
(12) }, /* International Date Line West */
403 { "cet", tZONE
, -HOURN
(1) }, /* Central European */
404 { "met", tZONE
, -HOURN
(1) }, /* Middle European */
405 { "mewt", tZONE
, -HOURN
(1) }, /* Middle European Winter */
406 { "mest", tDAYZONE
, -HOURN
(1) }, /* Middle European Summer */
407 { "swt", tZONE
, -HOURN
(1) }, /* Swedish Winter */
408 { "sst", tDAYZONE
, -HOURN
(1) }, /* Swedish Summer */
409 { "fwt", tZONE
, -HOURN
(1) }, /* French Winter */
410 { "fst", tDAYZONE
, -HOURN
(1) }, /* French Summer */
411 { "eet", tZONE
, -HOURN
(2) }, /* Eastern Europe, USSR Zone 1 */
412 { "bt", tZONE
, -HOURN
(3) }, /* Baghdad, USSR Zone 2 */
413 { "it", tZONE
, -HOURN
(3.5) },/* Iran */
414 { "zp4", tZONE
, -HOURN
(4) }, /* USSR Zone 3 */
415 { "zp5", tZONE
, -HOURN
(5) }, /* USSR Zone 4 */
416 { "ist", tZONE
, -HOURN
(5.5) },/* Indian Standard */
417 { "zp6", tZONE
, -HOURN
(6) }, /* USSR Zone 5 */
419 /* For completeness. NST is also Newfoundland Stanard, nad SST is
420 * also Swedish Summer. */
421 { "nst", tZONE
, -HOURN
(6.5) },/* North Sumatra */
422 { "sst", tZONE
, -HOURN
(7) }, /* South Sumatra, USSR Zone 6 */
424 { "wast", tZONE
, -HOURN
(7) }, /* West Australian Standard */
425 { "wadt", tDAYZONE
, -HOURN
(7) }, /* West Australian Daylight */
426 { "jt", tZONE
, -HOURN
(7.5) },/* Java (3pm in Cronusland!) */
427 { "cct", tZONE
, -HOURN
(8) }, /* China Coast, USSR Zone 7 */
428 { "jst", tZONE
, -HOURN
(9) }, /* Japan Standard, USSR Zone 8 */
429 { "cast", tZONE
, -HOURN
(9.5) },/* Central Australian Standard */
430 { "cadt", tDAYZONE
, -HOURN
(9.5) },/* Central Australian Daylight */
431 { "east", tZONE
, -HOURN
(10) }, /* Eastern Australian Standard */
432 { "eadt", tDAYZONE
, -HOURN
(10) }, /* Eastern Australian Daylight */
433 { "gst", tZONE
, -HOURN
(10) }, /* Guam Standard, USSR Zone 9 */
434 { "nzt", tZONE
, -HOURN
(12) }, /* New Zealand */
435 { "nzst", tZONE
, -HOURN
(12) }, /* New Zealand Standard */
436 { "nzdt", tDAYZONE
, -HOURN
(12) }, /* New Zealand Daylight */
437 { "idle", tZONE
, -HOURN
(12) }, /* International Date Line East */
441 /* Military timezone table. */
442 static TABLE MilitaryTable
[] = {
443 { "a", tZONE
, HOURN
( 1) },
444 { "b", tZONE
, HOURN
( 2) },
445 { "c", tZONE
, HOURN
( 3) },
446 { "d", tZONE
, HOURN
( 4) },
447 { "e", tZONE
, HOURN
( 5) },
448 { "f", tZONE
, HOURN
( 6) },
449 { "g", tZONE
, HOURN
( 7) },
450 { "h", tZONE
, HOURN
( 8) },
451 { "i", tZONE
, HOURN
( 9) },
452 { "k", tZONE
, HOURN
( 10) },
453 { "l", tZONE
, HOURN
( 11) },
454 { "m", tZONE
, HOURN
( 12) },
455 { "n", tZONE
, HOURN
(- 1) },
456 { "o", tZONE
, HOURN
(- 2) },
457 { "p", tZONE
, HOURN
(- 3) },
458 { "q", tZONE
, HOURN
(- 4) },
459 { "r", tZONE
, HOURN
(- 5) },
460 { "s", tZONE
, HOURN
(- 6) },
461 { "t", tZONE
, HOURN
(- 7) },
462 { "u", tZONE
, HOURN
(- 8) },
463 { "v", tZONE
, HOURN
(- 9) },
464 { "w", tZONE
, HOURN
(-10) },
465 { "x", tZONE
, HOURN
(-11) },
466 { "y", tZONE
, HOURN
(-12) },
467 { "z", tZONE
, HOURN
( 0) },
483 ToSeconds
(Hours
, Minutes
, Seconds
, Meridian
)
489 if
(Minutes
< 0 || Minutes
> 59 || Seconds
< 0 || Seconds
> 59)
493 if
(Hours
< 0 || Hours
> 23)
495 return
(Hours
* 60L + Minutes
) * 60L + Seconds
;
497 if
(Hours
< 1 || Hours
> 12)
500 return
(Hours
* 60L + Minutes
) * 60L + Seconds
;
502 return Minutes
* 60L + Seconds
;
504 if
(Hours
< 1 || Hours
> 12)
507 return
((Hours
+ 12) * 60L + Minutes
) * 60L + Seconds
;
509 return
(720L + Minutes
) * 60L + Seconds
;
517 Convert
(Month
, Day
, Year
, Hours
, Minutes
, Seconds
, Meridian
, DSTmode
)
527 static int DaysInMonth
[12] = {
528 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
538 DaysInMonth
[1] = Year %
4 == 0 && (Year %
100 != 0 || Year %
400 == 0)
540 if
(Year
< EPOCH || Year
> 2037
541 || Month
< 1 || Month
> 12
542 /* LINTED Month is a time_t so intermediate results aren't truncated */
543 || Day
< 1 || Day
> DaysInMonth
[(int)--Month
])
546 for
(Julian
= Day
- 1, i
= 0; i
< Month
; i
++)
547 Julian
+= DaysInMonth
[i
];
548 for
(i
= EPOCH
; i
< Year
; i
++)
549 Julian
+= 365 + (i %
4 == 0);
550 Julian
*= SECSPERDAY
;
551 Julian
+= yyTimezone
* 60L;
552 if
((tod
= ToSeconds
(Hours
, Minutes
, Seconds
, Meridian
)) < 0)
556 ||
(DSTmode
== DSTmaybe
&& localtime
(&Julian
)->tm_isdst
))
563 DSTcorrect
(Start
, Future
)
570 StartDay
= (localtime
(&Start
)->tm_hour
+ 1) %
24;
571 FutureDay
= (localtime
(&Future
)->tm_hour
+ 1) %
24;
572 return
(Future
- Start
) + (StartDay
- FutureDay
) * 60L * 60L;
577 RelativeDate
(Start
, DayOrdinal
, DayNumber
)
586 tm
= localtime
(&now
);
587 now
+= SECSPERDAY
* ((DayNumber
- tm
->tm_wday
+ 7) %
7);
588 now
+= 7 * SECSPERDAY
* (DayOrdinal
<= 0 ? DayOrdinal
: DayOrdinal
- 1);
589 return DSTcorrect
(Start
, now
);
594 RelativeMonth
(Start
, RelMonth
)
604 tm
= localtime
(&Start
);
605 Month
= 12 * tm
->tm_year
+ tm
->tm_mon
+ RelMonth
;
607 Month
= Month %
12 + 1;
608 return DSTcorrect
(Start
,
609 Convert
(Month
, (time_t)tm
->tm_mday
, Year
,
610 (time_t)tm
->tm_hour
, (time_t)tm
->tm_min
, (time_t)tm
->tm_sec
,
625 /* Make it lowercase. */
626 for
(p
= buff
; *p
; p
++)
627 if
(isupper
((u_char
)*p
))
630 if
(strcmp
(buff
, "am") == 0 || strcmp
(buff
, "a.m.") == 0) {
631 yylval.Meridian
= MERam
;
634 if
(strcmp
(buff
, "pm") == 0 || strcmp
(buff
, "p.m.") == 0) {
635 yylval.Meridian
= MERpm
;
639 /* See if we have an abbreviation for a month. */
640 if
(strlen
(buff
) == 3)
642 else if
(strlen
(buff
) == 4 && buff
[3] == '.') {
649 for
(tp
= MonthDayTable
; tp
->name
; tp
++) {
651 if
(strncmp
(buff
, tp
->name
, 3) == 0) {
652 yylval.Number
= tp
->value
;
656 else if
(strcmp
(buff
, tp
->name
) == 0) {
657 yylval.Number
= tp
->value
;
662 for
(tp
= TimezoneTable
; tp
->name
; tp
++)
663 if
(strcmp
(buff
, tp
->name
) == 0) {
664 yylval.Number
= tp
->value
;
668 for
(tp
= UnitsTable
; tp
->name
; tp
++)
669 if
(strcmp
(buff
, tp
->name
) == 0) {
670 yylval.Number
= tp
->value
;
674 /* Strip off any plural and try the units table again. */
675 i
= strlen
(buff
) - 1;
676 if
(buff
[i
] == 's') {
678 for
(tp
= UnitsTable
; tp
->name
; tp
++)
679 if
(strcmp
(buff
, tp
->name
) == 0) {
680 yylval.Number
= tp
->value
;
685 for
(tp
= OtherTable
; tp
->name
; tp
++)
686 if
(strcmp
(buff
, tp
->name
) == 0) {
687 yylval.Number
= tp
->value
;
691 /* Military timezones. */
692 if
(buff
[1] == '\0' && isalpha
((u_char
)*buff
)) {
693 for
(tp
= MilitaryTable
; tp
->name
; tp
++)
694 if
(strcmp
(buff
, tp
->name
) == 0) {
695 yylval.Number
= tp
->value
;
700 /* Drop out any periods and try the timezone table again. */
701 for
(i
= 0, p
= q
= buff
; *q
; q
++)
708 for
(tp
= TimezoneTable
; tp
->name
; tp
++)
709 if
(strcmp
(buff
, tp
->name
) == 0) {
710 yylval.Number
= tp
->value
;
721 char *name
= "DATEMSK"; /* env variable for date format */
723 char fmt
[256], line
[256];
728 value
= getenv
(name
);
729 if
(value
== (char *)0) {
731 dgettext
(domainname
, "%s: Environment variable %s not set\n"),
735 switch
(getdate_err
) {
739 dgettext
(domainname
, "%s: Unkown getdate() error\n"), p
);
743 dgettext
(domainname
, "%s: %s null or undefined\n"), p
, name
);
746 fprintf
(stderr
, dgettext
(domainname
,
747 "%s: Cannot read template file %s\n"), p
, value
);
750 fprintf
(stderr
, dgettext
(domainname
,
751 "%s: Failed to get file status information\n"), p
);
754 fprintf
(stderr
, dgettext
(domainname
,
755 "%s: Template file %s not a regular file\n"), p
, value
);
758 fprintf
(stderr
, dgettext
(domainname
,
759 "%s: Error reading template file %s\n"), p
, value
);
762 fprintf
(stderr
, dgettext
(domainname
,
763 "%s: %s failed\n"), p
, "malloc()");
766 fprintf
(stderr
, dgettext
(domainname
,
767 "%s: Bad date/time format\n"), p
);
768 fp
= fopen
(value
, "r");
771 now
= time
((time_t *)0);
772 tm
= localtime
(&now
);
773 fprintf
(stderr
, dgettext
(domainname
,
774 "The following are examples of valid formats:\n"));
775 while
(fgets
(fmt
, sizeof
(fmt
), fp
)) {
776 if
(strchr
(fmt
, '%') == (char *)0)
778 fprintf
(stderr
, " ");
779 (void) strftime
(line
, sizeof
(line
), fmt
, tm
);
780 fprintf
(stderr
, "%s", line
);
785 (void) fprintf
(stderr
, dgettext
(domainname
,
786 "%s: Invalid date specification\n"), p
);
802 while
(isspace
((u_char
)*yyInput
))
805 if
(isdigit
((u_char
)(c
= *yyInput
)) || c
== '-' || c
== '+') {
806 if
(c
== '-' || c
== '+') {
807 sign
= c
== '-' ?
-1 : 1;
808 if
(!isdigit
((u_char
)*++yyInput
))
809 /* skip the '-' sign */
815 while
(isdigit
((u_char
)(c
= *yyInput
++))) {
818 (void) sscanf
(&digit
, "%1d", &n
);
819 yylval.Number
= 10 * yylval.Number
+ n
;
823 yylval.Number
= -yylval.Number
;
824 return sign ? tSNUMBER
: tUNUMBER
;
826 if
(isalpha
((u_char
)c
)) {
827 for
(p
= buff
; isalpha
((u_char
)(c
= *yyInput
++)) || c
== '.'; )
828 if
(p
< &buff
[sizeof
(buff
) - 1])
832 return LookupWord
(buff
);
860 if
(strcmp
(setlocale
(LC_TIME
, NULL
), "C")) {
861 static char localedate
[24];
865 if
(getdate_err
== 1 /* NODATEMASK */) {
869 printf
(gettext
("environment variable %s not set\n"), "DATEMSK");
872 tm
= localtime
(¤t
);
873 memcpy
(<m
, tm
, sizeof
(ltm
));
876 (void) fputs
(gettext
("Enter date as mmddhhmm[yy]: "), stdout
);
877 (void) fflush
(stdout
);
878 if
(fgets
(buffy
, sizeof
(buffy
), stdin
) == NULL
) {
879 (void) printf
(gettext
("Encountered EOF on stdin\n"));
882 } while
(sscanf
(buffy
, "%2d%2d%2d%2d%2d",
883 &(tm
->tm_mon
), &(tm
->tm_mday
), &(tm
->tm_hour
),
884 &(tm
->tm_min
), &(tm
->tm_year
)) < 4);
887 } else if
(tm
== NULL
)
890 (void)sprintf
(localedate
, "%d:%2.2d %d/%d %d",
891 tm
->tm_hour
, tm
->tm_min
, tm
->tm_mon
+ 1,
892 tm
->tm_mday
, CHECK_TM
(tm
->tm_year
));
899 (void) time
(&ftz.time
);
900 /* Set the timezone global. */
902 /* LINTED timezone is time_t so intermediate results aren't truncated */
903 ftz.timezone
= (int) timezone
/ 60;
906 tm
= localtime
(&now
->time
);
907 yyYear
= tm
->tm_year
;
908 yyMonth
= tm
->tm_mon
+ 1;
910 yyTimezone
= now
->timezone
;
911 yyDSTmode
= DSTmaybe
;
912 yyHour
= tm
->tm_hour
;
913 yyMinutes
= tm
->tm_min
;
914 yySeconds
= tm
->tm_sec
;
925 || yyHaveTime
> 1 || yyHaveZone
> 1 || yyHaveDate
> 1 || yyHaveDay
> 1)
928 if
(yyHaveDate || yyHaveTime || yyHaveDay
) {
929 Start
= Convert
(yyMonth
, yyDay
, yyYear
, yyHour
, yyMinutes
, yySeconds
,
930 yyMeridian
, yyDSTmode
);
937 Start
-= ((tm
->tm_hour
* 60L) + tm
->tm_min
* 60L) + tm
->tm_sec
;
940 Start
+= yyRelSeconds
;
941 Start
+= RelativeMonth
(Start
, yyRelMonth
);
943 if
(yyHaveDay
&& !yyHaveDate
) {
944 tod
= RelativeDate
(Start
, yyDayOrdinal
, yyDayNumber
);
948 /* Have to do *something* with a legitimate -1 so it's distinguishable
949 * from the error return value. (Alternately could set errno on error.) */
950 return Start
== -1 ?
0 : Start
;
963 (void) setlocale
(LC_ALL
, "");
964 #if !defined(TEXT_DOMAIN)
965 #define TEXT_DOMAIN "SYS_TEST"
967 (void) textdomain
(TEXT_DOMAIN
);
969 (void) printf
(gettext
("Enter date, or blank line to exit.\n\t> "));
970 (void) fflush
(stdout
);
971 while
(gets
(buff
) && buff
[0]) {
972 d
= getreldate
(buff
, (struct timeb
*)NULL
);
974 (void) printf
(gettext
("Bad format - couldn't convert.\n"));
976 (void) cftime
(buff
, "%c\n", &d
);
977 (void) printf
("%s", buff
);
979 (void) printf
("\t> ");
980 (void) fflush
(stdout
);
985 #endif /* defined(TEST) */