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 */
42 "$Header: /home/laramie/berliner/ws/backup/usr/src/cmd/backup/lib/getdate.y,v 1.5 1992/06/09 21:46:21 sam Exp $";
46 #define HOURN(x) (x * 60)
47 #define SECSPERDAY (24L * 60L * 60L)
49 #define CHECK_TM(y) (((y) % 100) < 70 ? (y) + 2000 : (y) + 1900)
52 ** An entry in the lexical lookup table.
54 typedef
struct _TABLE
{
62 ** Daylight-savings mode: on, off, or not yet known.
64 typedef
enum _DSTMODE
{
65 DSTon
, DSToff
, DSTmaybe
69 ** Meridian: am, pm, or 24-hour style.
71 typedef
enum _MERIDIAN
{
77 ** Global variables. We could get rid of most of these by using a good
78 ** union as the yacc stack. (This routine was originally written before
79 ** yacc had the %union construct.) Maybe someday; right now we only use
80 ** the %union very rarely.
83 static DSTMODE yyDSTmode
;
84 static time_t yyDayOrdinal
;
85 static time_t yyDayNumber
;
86 static int yyHaveDate
;
89 static int yyHaveTime
;
90 static int yyHaveZone
;
91 static time_t yyTimezone
;
94 static time_t yyMinutes
;
95 static time_t yyMonth
;
96 static time_t yySeconds
;
98 static MERIDIAN yyMeridian
;
99 static time_t yyRelMonth
;
100 static time_t yyRelSeconds
;
102 static char *domainname
= "hsm_libdump"; /* for dgettext() */
104 #define yylex 1 /* suppress yacc's definition */
109 enum _MERIDIAN Meridian
;
112 %token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
113 %token tSEC_UNIT tSNUMBER tUNUMBER tZONE
115 %type
<Number
> tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT
116 %type
<Number
> tSEC_UNIT tSNUMBER tUNUMBER tZONE
117 %type
<Meridian
> tMERIDIAN o_merid
143 time
: tUNUMBER tMERIDIAN
{
149 | tUNUMBER
':' tUNUMBER o_merid
{
155 | tUNUMBER
':' tUNUMBER tSNUMBER
{
160 yyTimezone
= - ($4 %
100 + ($4 / 100) * 60);
162 | tUNUMBER
':' tUNUMBER
':' tUNUMBER o_merid
{
168 | tUNUMBER
':' tUNUMBER
':' tUNUMBER tSNUMBER
{
174 yyTimezone
= - ($6 %
100 + ($6 / 100) * 60);
202 date
: tUNUMBER
'/' tUNUMBER
{
206 | tUNUMBER
'/' tUNUMBER
'/' tUNUMBER
{
215 | tMONTH tUNUMBER
',' tUNUMBER
{
224 | tUNUMBER tMONTH tUNUMBER
{
232 yyRelSeconds
= -yyRelSeconds
;
233 yyRelMonth
= -yyRelMonth
;
238 relunit
: tUNUMBER tMINUTE_UNIT
{
239 yyRelSeconds
+= $1 * $2 * 60L;
241 | tSNUMBER tMINUTE_UNIT
{
242 yyRelSeconds
+= $1 * $2 * 60L;
245 yyRelSeconds
+= $1 * 60L;
247 | tSNUMBER tSEC_UNIT
{
250 | tUNUMBER tSEC_UNIT
{
256 | tSNUMBER tMONTH_UNIT
{
257 yyRelMonth
+= $1 * $2;
259 | tUNUMBER tMONTH_UNIT
{
260 yyRelMonth
+= $1 * $2;
268 if
(yyHaveTime
&& yyHaveDate
&& !yyHaveRel
)
278 yyMinutes
= $1 %
100;
286 o_merid
: /* NULL */ {
296 /* Month and day table. */
297 static TABLE MonthDayTable
[] = {
298 { "january", tMONTH
, 1 },
299 { "february", tMONTH
, 2 },
300 { "march", tMONTH
, 3 },
301 { "april", tMONTH
, 4 },
302 { "may", tMONTH
, 5 },
303 { "june", tMONTH
, 6 },
304 { "july", tMONTH
, 7 },
305 { "august", tMONTH
, 8 },
306 { "september", tMONTH
, 9 },
307 { "sept", tMONTH
, 9 },
308 { "october", tMONTH
, 10 },
309 { "november", tMONTH
, 11 },
310 { "december", tMONTH
, 12 },
311 { "sunday", tDAY
, 0 },
312 { "monday", tDAY
, 1 },
313 { "tuesday", tDAY
, 2 },
315 { "wednesday", tDAY
, 3 },
316 { "wednes", tDAY
, 3 },
317 { "thursday", tDAY
, 4 },
319 { "thurs", tDAY
, 4 },
320 { "friday", tDAY
, 5 },
321 { "saturday", tDAY
, 6 },
325 /* Time units table. */
326 static TABLE UnitsTable
[] = {
327 { "year", tMONTH_UNIT
, 12 },
328 { "month", tMONTH_UNIT
, 1 },
329 { "fortnight", tMINUTE_UNIT
, 14 * 24 * 60 },
330 { "week", tMINUTE_UNIT
, 7 * 24 * 60 },
331 { "day", tMINUTE_UNIT
, 1 * 24 * 60 },
332 { "hour", tMINUTE_UNIT
, 60 },
333 { "minute", tMINUTE_UNIT
, 1 },
334 { "min", tMINUTE_UNIT
, 1 },
335 { "second", tSEC_UNIT
, 1 },
336 { "sec", tSEC_UNIT
, 1 },
340 /* Assorted relative-time words. */
341 static TABLE OtherTable
[] = {
342 { "tomorrow", tMINUTE_UNIT
, 1 * 24 * 60 },
343 { "yesterday", tMINUTE_UNIT
, -1 * 24 * 60 },
344 { "today", tMINUTE_UNIT
, 0 },
345 { "now", tMINUTE_UNIT
, 0 },
346 { "last", tUNUMBER
, -1 },
347 { "this", tMINUTE_UNIT
, 0 },
348 { "next", tUNUMBER
, 2 },
349 { "first", tUNUMBER
, 1 },
350 /* { "second", tUNUMBER, 2 }, */
351 { "third", tUNUMBER
, 3 },
352 { "fourth", tUNUMBER
, 4 },
353 { "fifth", tUNUMBER
, 5 },
354 { "sixth", tUNUMBER
, 6 },
355 { "seventh", tUNUMBER
, 7 },
356 { "eighth", tUNUMBER
, 8 },
357 { "ninth", tUNUMBER
, 9 },
358 { "tenth", tUNUMBER
, 10 },
359 { "eleventh", tUNUMBER
, 11 },
360 { "twelfth", tUNUMBER
, 12 },
365 /* The timezone table. */
366 static TABLE TimezoneTable
[] = {
367 { "gmt", tZONE
, HOURN
( 0) }, /* Greenwich Mean */
368 { "ut", tZONE
, HOURN
( 0) }, /* Universal (Coordinated) */
369 { "utc", tZONE
, HOURN
( 0) },
370 { "wet", tZONE
, HOURN
( 0) }, /* Western European */
371 { "bst", tDAYZONE
, HOURN
( 0) }, /* British Summer */
372 { "wat", tZONE
, HOURN
( 1) }, /* West Africa */
373 { "at", tZONE
, HOURN
( 2) }, /* Azores */
375 /* For completeness. BST is also British Summer, and GST is
376 * also Guam Standard. */
377 { "bst", tZONE
, HOURN
( 3) }, /* Brazil Standard */
378 { "gst", tZONE
, HOURN
( 3) }, /* Greenland Standard */
380 { "nft", tZONE
, HOURN
(3.5) }, /* Newfoundland */
381 { "nst", tZONE
, HOURN
(3.5) }, /* Newfoundland Standard */
382 { "ndt", tDAYZONE
, HOURN
(3.5) }, /* Newfoundland Daylight */
383 { "ast", tZONE
, HOURN
( 4) }, /* Atlantic Standard */
384 { "adt", tDAYZONE
, HOURN
( 4) }, /* Atlantic Daylight */
385 { "est", tZONE
, HOURN
( 5) }, /* Eastern Standard */
386 { "edt", tDAYZONE
, HOURN
( 5) }, /* Eastern Daylight */
387 { "cst", tZONE
, HOURN
( 6) }, /* Central Standard */
388 { "cdt", tDAYZONE
, HOURN
( 6) }, /* Central Daylight */
389 { "mst", tZONE
, HOURN
( 7) }, /* Mountain Standard */
390 { "mdt", tDAYZONE
, HOURN
( 7) }, /* Mountain Daylight */
391 { "pst", tZONE
, HOURN
( 8) }, /* Pacific Standard */
392 { "pdt", tDAYZONE
, HOURN
( 8) }, /* Pacific Daylight */
393 { "yst", tZONE
, HOURN
( 9) }, /* Yukon Standard */
394 { "ydt", tDAYZONE
, HOURN
( 9) }, /* Yukon Daylight */
395 { "hst", tZONE
, HOURN
(10) }, /* Hawaii Standard */
396 { "hdt", tDAYZONE
, HOURN
(10) }, /* Hawaii Daylight */
397 { "cat", tZONE
, HOURN
(10) }, /* Central Alaska */
398 { "ahst", tZONE
, HOURN
(10) }, /* Alaska-Hawaii Standard */
399 { "nt", tZONE
, HOURN
(11) }, /* Nome */
400 { "idlw", tZONE
, HOURN
(12) }, /* International Date Line West */
401 { "cet", tZONE
, -HOURN
(1) }, /* Central European */
402 { "met", tZONE
, -HOURN
(1) }, /* Middle European */
403 { "mewt", tZONE
, -HOURN
(1) }, /* Middle European Winter */
404 { "mest", tDAYZONE
, -HOURN
(1) }, /* Middle European Summer */
405 { "swt", tZONE
, -HOURN
(1) }, /* Swedish Winter */
406 { "sst", tDAYZONE
, -HOURN
(1) }, /* Swedish Summer */
407 { "fwt", tZONE
, -HOURN
(1) }, /* French Winter */
408 { "fst", tDAYZONE
, -HOURN
(1) }, /* French Summer */
409 { "eet", tZONE
, -HOURN
(2) }, /* Eastern Europe, USSR Zone 1 */
410 { "bt", tZONE
, -HOURN
(3) }, /* Baghdad, USSR Zone 2 */
411 { "it", tZONE
, -HOURN
(3.5) },/* Iran */
412 { "zp4", tZONE
, -HOURN
(4) }, /* USSR Zone 3 */
413 { "zp5", tZONE
, -HOURN
(5) }, /* USSR Zone 4 */
414 { "ist", tZONE
, -HOURN
(5.5) },/* Indian Standard */
415 { "zp6", tZONE
, -HOURN
(6) }, /* USSR Zone 5 */
417 /* For completeness. NST is also Newfoundland Stanard, nad SST is
418 * also Swedish Summer. */
419 { "nst", tZONE
, -HOURN
(6.5) },/* North Sumatra */
420 { "sst", tZONE
, -HOURN
(7) }, /* South Sumatra, USSR Zone 6 */
422 { "wast", tZONE
, -HOURN
(7) }, /* West Australian Standard */
423 { "wadt", tDAYZONE
, -HOURN
(7) }, /* West Australian Daylight */
424 { "jt", tZONE
, -HOURN
(7.5) },/* Java (3pm in Cronusland!) */
425 { "cct", tZONE
, -HOURN
(8) }, /* China Coast, USSR Zone 7 */
426 { "jst", tZONE
, -HOURN
(9) }, /* Japan Standard, USSR Zone 8 */
427 { "cast", tZONE
, -HOURN
(9.5) },/* Central Australian Standard */
428 { "cadt", tDAYZONE
, -HOURN
(9.5) },/* Central Australian Daylight */
429 { "east", tZONE
, -HOURN
(10) }, /* Eastern Australian Standard */
430 { "eadt", tDAYZONE
, -HOURN
(10) }, /* Eastern Australian Daylight */
431 { "gst", tZONE
, -HOURN
(10) }, /* Guam Standard, USSR Zone 9 */
432 { "nzt", tZONE
, -HOURN
(12) }, /* New Zealand */
433 { "nzst", tZONE
, -HOURN
(12) }, /* New Zealand Standard */
434 { "nzdt", tDAYZONE
, -HOURN
(12) }, /* New Zealand Daylight */
435 { "idle", tZONE
, -HOURN
(12) }, /* International Date Line East */
439 /* Military timezone table. */
440 static TABLE MilitaryTable
[] = {
441 { "a", tZONE
, HOURN
( 1) },
442 { "b", tZONE
, HOURN
( 2) },
443 { "c", tZONE
, HOURN
( 3) },
444 { "d", tZONE
, HOURN
( 4) },
445 { "e", tZONE
, HOURN
( 5) },
446 { "f", tZONE
, HOURN
( 6) },
447 { "g", tZONE
, HOURN
( 7) },
448 { "h", tZONE
, HOURN
( 8) },
449 { "i", tZONE
, HOURN
( 9) },
450 { "k", tZONE
, HOURN
( 10) },
451 { "l", tZONE
, HOURN
( 11) },
452 { "m", tZONE
, HOURN
( 12) },
453 { "n", tZONE
, HOURN
(- 1) },
454 { "o", tZONE
, HOURN
(- 2) },
455 { "p", tZONE
, HOURN
(- 3) },
456 { "q", tZONE
, HOURN
(- 4) },
457 { "r", tZONE
, HOURN
(- 5) },
458 { "s", tZONE
, HOURN
(- 6) },
459 { "t", tZONE
, HOURN
(- 7) },
460 { "u", tZONE
, HOURN
(- 8) },
461 { "v", tZONE
, HOURN
(- 9) },
462 { "w", tZONE
, HOURN
(-10) },
463 { "x", tZONE
, HOURN
(-11) },
464 { "y", tZONE
, HOURN
(-12) },
465 { "z", tZONE
, HOURN
( 0) },
481 ToSeconds
(Hours
, Minutes
, Seconds
, Meridian
)
487 if
(Minutes
< 0 || Minutes
> 59 || Seconds
< 0 || Seconds
> 59)
491 if
(Hours
< 0 || Hours
> 23)
493 return
(Hours
* 60L + Minutes
) * 60L + Seconds
;
495 if
(Hours
< 1 || Hours
> 12)
498 return
(Hours
* 60L + Minutes
) * 60L + Seconds
;
500 return Minutes
* 60L + Seconds
;
502 if
(Hours
< 1 || Hours
> 12)
505 return
((Hours
+ 12) * 60L + Minutes
) * 60L + Seconds
;
507 return
(720L + Minutes
) * 60L + Seconds
;
515 Convert
(Month
, Day
, Year
, Hours
, Minutes
, Seconds
, Meridian
, DSTmode
)
525 static int DaysInMonth
[12] = {
526 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
536 DaysInMonth
[1] = Year %
4 == 0 && (Year %
100 != 0 || Year %
400 == 0)
538 if
(Year
< EPOCH || Year
> 2037
539 || Month
< 1 || Month
> 12
540 /* LINTED Month is a time_t so intermediate results aren't truncated */
541 || Day
< 1 || Day
> DaysInMonth
[(int)--Month
])
544 for
(Julian
= Day
- 1, i
= 0; i
< Month
; i
++)
545 Julian
+= DaysInMonth
[i
];
546 for
(i
= EPOCH
; i
< Year
; i
++)
547 Julian
+= 365 + (i %
4 == 0);
548 Julian
*= SECSPERDAY
;
549 Julian
+= yyTimezone
* 60L;
550 if
((tod
= ToSeconds
(Hours
, Minutes
, Seconds
, Meridian
)) < 0)
554 ||
(DSTmode
== DSTmaybe
&& localtime
(&Julian
)->tm_isdst
))
561 DSTcorrect
(Start
, Future
)
568 StartDay
= (localtime
(&Start
)->tm_hour
+ 1) %
24;
569 FutureDay
= (localtime
(&Future
)->tm_hour
+ 1) %
24;
570 return
(Future
- Start
) + (StartDay
- FutureDay
) * 60L * 60L;
575 RelativeDate
(Start
, DayOrdinal
, DayNumber
)
584 tm
= localtime
(&now
);
585 now
+= SECSPERDAY
* ((DayNumber
- tm
->tm_wday
+ 7) %
7);
586 now
+= 7 * SECSPERDAY
* (DayOrdinal
<= 0 ? DayOrdinal
: DayOrdinal
- 1);
587 return DSTcorrect
(Start
, now
);
592 RelativeMonth
(Start
, RelMonth
)
602 tm
= localtime
(&Start
);
603 Month
= 12 * tm
->tm_year
+ tm
->tm_mon
+ RelMonth
;
605 Month
= Month %
12 + 1;
606 return DSTcorrect
(Start
,
607 Convert
(Month
, (time_t)tm
->tm_mday
, Year
,
608 (time_t)tm
->tm_hour
, (time_t)tm
->tm_min
, (time_t)tm
->tm_sec
,
623 /* Make it lowercase. */
624 for
(p
= buff
; *p
; p
++)
625 if
(isupper
((u_char
)*p
))
628 if
(strcmp
(buff
, "am") == 0 || strcmp
(buff
, "a.m.") == 0) {
629 yylval.Meridian
= MERam
;
632 if
(strcmp
(buff
, "pm") == 0 || strcmp
(buff
, "p.m.") == 0) {
633 yylval.Meridian
= MERpm
;
637 /* See if we have an abbreviation for a month. */
638 if
(strlen
(buff
) == 3)
640 else if
(strlen
(buff
) == 4 && buff
[3] == '.') {
647 for
(tp
= MonthDayTable
; tp
->name
; tp
++) {
649 if
(strncmp
(buff
, tp
->name
, 3) == 0) {
650 yylval.Number
= tp
->value
;
654 else if
(strcmp
(buff
, tp
->name
) == 0) {
655 yylval.Number
= tp
->value
;
660 for
(tp
= TimezoneTable
; tp
->name
; tp
++)
661 if
(strcmp
(buff
, tp
->name
) == 0) {
662 yylval.Number
= tp
->value
;
666 for
(tp
= UnitsTable
; tp
->name
; tp
++)
667 if
(strcmp
(buff
, tp
->name
) == 0) {
668 yylval.Number
= tp
->value
;
672 /* Strip off any plural and try the units table again. */
673 i
= strlen
(buff
) - 1;
674 if
(buff
[i
] == 's') {
676 for
(tp
= UnitsTable
; tp
->name
; tp
++)
677 if
(strcmp
(buff
, tp
->name
) == 0) {
678 yylval.Number
= tp
->value
;
683 for
(tp
= OtherTable
; tp
->name
; tp
++)
684 if
(strcmp
(buff
, tp
->name
) == 0) {
685 yylval.Number
= tp
->value
;
689 /* Military timezones. */
690 if
(buff
[1] == '\0' && isalpha
((u_char
)*buff
)) {
691 for
(tp
= MilitaryTable
; tp
->name
; tp
++)
692 if
(strcmp
(buff
, tp
->name
) == 0) {
693 yylval.Number
= tp
->value
;
698 /* Drop out any periods and try the timezone table again. */
699 for
(i
= 0, p
= q
= buff
; *q
; q
++)
706 for
(tp
= TimezoneTable
; tp
->name
; tp
++)
707 if
(strcmp
(buff
, tp
->name
) == 0) {
708 yylval.Number
= tp
->value
;
719 char *name
= "DATEMSK"; /* env variable for date format */
721 char fmt
[256], line
[256];
726 value
= getenv
(name
);
729 dgettext
(domainname
, "%s: Environment variable %s not set\n"),
733 switch
(getdate_err
) {
737 dgettext
(domainname
, "%s: Unkown getdate() error\n"), p
);
741 dgettext
(domainname
, "%s: %s null or undefined\n"), p
, name
);
744 fprintf
(stderr
, dgettext
(domainname
,
745 "%s: Cannot read template file %s\n"), p
, value
);
748 fprintf
(stderr
, dgettext
(domainname
,
749 "%s: Failed to get file status information\n"), p
);
752 fprintf
(stderr
, dgettext
(domainname
,
753 "%s: Template file %s not a regular file\n"), p
, value
);
756 fprintf
(stderr
, dgettext
(domainname
,
757 "%s: Error reading template file %s\n"), p
, value
);
760 fprintf
(stderr
, dgettext
(domainname
,
761 "%s: %s failed\n"), p
, "malloc()");
764 fprintf
(stderr
, dgettext
(domainname
,
765 "%s: Bad date/time format\n"), p
);
766 fp
= fopen
(value
, "r");
769 now
= time
((time_t *)0);
770 tm
= localtime
(&now
);
771 fprintf
(stderr
, dgettext
(domainname
,
772 "The following are examples of valid formats:\n"));
773 while
(fgets
(fmt
, sizeof
(fmt
), fp
)) {
774 if
(strchr
(fmt
, '%') == NULL
)
776 fprintf
(stderr
, " ");
777 (void) strftime
(line
, sizeof
(line
), fmt
, tm
);
778 fprintf
(stderr
, "%s", line
);
783 (void) fprintf
(stderr
, dgettext
(domainname
,
784 "%s: Invalid date specification\n"), p
);
800 while
(isspace
((u_char
)*yyInput
))
803 if
(isdigit
((u_char
)(c
= *yyInput
)) || c
== '-' || c
== '+') {
804 if
(c
== '-' || c
== '+') {
805 sign
= c
== '-' ?
-1 : 1;
806 if
(!isdigit
((u_char
)*++yyInput
))
807 /* skip the '-' sign */
813 while
(isdigit
((u_char
)(c
= *yyInput
++))) {
816 (void) sscanf
(&digit
, "%1d", &n
);
817 yylval.Number
= 10 * yylval.Number
+ n
;
821 yylval.Number
= -yylval.Number
;
822 return sign ? tSNUMBER
: tUNUMBER
;
824 if
(isalpha
((u_char
)c
)) {
825 for
(p
= buff
; isalpha
((u_char
)(c
= *yyInput
++)) || c
== '.'; )
826 if
(p
< &buff
[sizeof
(buff
) - 1])
830 return LookupWord
(buff
);
858 if
(strcmp
(setlocale
(LC_TIME
, NULL
), "C")) {
859 static char localedate
[24];
863 if
(getdate_err
== 1 /* NODATEMASK */) {
867 printf
(gettext
("environment variable %s not set\n"), "DATEMSK");
870 tm
= localtime
(¤t
);
871 memcpy
(<m
, tm
, sizeof
(ltm
));
874 (void) fputs
(gettext
("Enter date as mmddhhmm[yy]: "), stdout
);
875 (void) fflush
(stdout
);
876 if
(fgets
(buffy
, sizeof
(buffy
), stdin
) == NULL
) {
877 (void) printf
(gettext
("Encountered EOF on stdin\n"));
880 } while
(sscanf
(buffy
, "%2d%2d%2d%2d%2d",
881 &(tm
->tm_mon
), &(tm
->tm_mday
), &(tm
->tm_hour
),
882 &(tm
->tm_min
), &(tm
->tm_year
)) < 4);
885 } else if
(tm
== NULL
)
888 (void)sprintf
(localedate
, "%d:%2.2d %d/%d %d",
889 tm
->tm_hour
, tm
->tm_min
, tm
->tm_mon
+ 1,
890 tm
->tm_mday
, CHECK_TM
(tm
->tm_year
));
897 (void) time
(&ftz.time
);
898 /* Set the timezone global. */
900 /* LINTED timezone is time_t so intermediate results aren't truncated */
901 ftz.timezone
= (int) timezone
/ 60;
904 tm
= localtime
(&now
->time
);
905 yyYear
= tm
->tm_year
;
906 yyMonth
= tm
->tm_mon
+ 1;
908 yyTimezone
= now
->timezone
;
909 yyDSTmode
= DSTmaybe
;
910 yyHour
= tm
->tm_hour
;
911 yyMinutes
= tm
->tm_min
;
912 yySeconds
= tm
->tm_sec
;
923 || yyHaveTime
> 1 || yyHaveZone
> 1 || yyHaveDate
> 1 || yyHaveDay
> 1)
926 if
(yyHaveDate || yyHaveTime || yyHaveDay
) {
927 Start
= Convert
(yyMonth
, yyDay
, yyYear
, yyHour
, yyMinutes
, yySeconds
,
928 yyMeridian
, yyDSTmode
);
935 Start
-= ((tm
->tm_hour
* 60L) + tm
->tm_min
* 60L) + tm
->tm_sec
;
938 Start
+= yyRelSeconds
;
939 Start
+= RelativeMonth
(Start
, yyRelMonth
);
941 if
(yyHaveDay
&& !yyHaveDate
) {
942 tod
= RelativeDate
(Start
, yyDayOrdinal
, yyDayNumber
);
946 /* Have to do *something* with a legitimate -1 so it's distinguishable
947 * from the error return value. (Alternately could set errno on error.) */
948 return Start
== -1 ?
0 : Start
;
961 (void) setlocale
(LC_ALL
, "");
962 #if !defined(TEXT_DOMAIN)
963 #define TEXT_DOMAIN "SYS_TEST"
965 (void) textdomain
(TEXT_DOMAIN
);
967 (void) printf
(gettext
("Enter date, or blank line to exit.\n\t> "));
968 (void) fflush
(stdout
);
969 while
(gets
(buff
) && buff
[0]) {
970 d
= getreldate
(buff
, NULL
);
972 (void) printf
(gettext
("Bad format - couldn't convert.\n"));
974 (void) cftime
(buff
, "%c\n", &d
);
975 (void) printf
("%s", buff
);
977 (void) printf
("\t> ");
978 (void) fflush
(stdout
);
983 #endif /* defined(TEST) */