@@ -342,7 +342,7 @@ j2date(int jd, int *year, int *month, int *day)
342342* year = y - 4800 ;
343343quad = julian * 2141 /65536 ;
344344* day = julian - 7834 * quad /256 ;
345- * month = (quad + 10 ) %12 + 1 ;
345+ * month = (quad + 10 ) %MONTHS_PER_YEAR + 1 ;
346346
347347return ;
348348}/* j2date() */
@@ -952,8 +952,8 @@ DecodeDateTime(char **field, int *ftype, int nf,
952952 * DecodeTime()
953953 */
954954/* test for > 24:00:00 */
955- if (tm -> tm_hour > 24 ||
956- (tm -> tm_hour == 24 &&
955+ if (tm -> tm_hour > HOURS_PER_DAY ||
956+ (tm -> tm_hour == HOURS_PER_DAY &&
957957 (tm -> tm_min > 0 || tm -> tm_sec > 0 || * fsec > 0 )))
958958return DTERR_FIELD_OVERFLOW ;
959959break ;
@@ -1371,12 +1371,12 @@ DecodeDateTime(char **field, int *ftype, int nf,
13711371return dterr ;
13721372
13731373/* handle AM/PM */
1374- if (mer != HR24 && tm -> tm_hour > 12 )
1374+ if (mer != HR24 && tm -> tm_hour > HOURS_PER_DAY / 2 )
13751375return DTERR_FIELD_OVERFLOW ;
1376- if (mer == AM && tm -> tm_hour == 12 )
1376+ if (mer == AM && tm -> tm_hour == HOURS_PER_DAY / 2 )
13771377tm -> tm_hour = 0 ;
1378- else if (mer == PM && tm -> tm_hour != 12 )
1379- tm -> tm_hour += 12 ;
1378+ else if (mer == PM && tm -> tm_hour != HOURS_PER_DAY / 2 )
1379+ tm -> tm_hour += HOURS_PER_DAY / 2 ;
13801380
13811381/* do additional checking for full date specs... */
13821382if (* dtype == DTK_DATE )
@@ -2058,17 +2058,18 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
20582058return dterr ;
20592059
20602060/* handle AM/PM */
2061- if (mer != HR24 && tm -> tm_hour > 12 )
2061+ if (mer != HR24 && tm -> tm_hour > HOURS_PER_DAY / 2 )
20622062return DTERR_FIELD_OVERFLOW ;
2063- if (mer == AM && tm -> tm_hour == 12 )
2063+ if (mer == AM && tm -> tm_hour == HOURS_PER_DAY / 2 )
20642064tm -> tm_hour = 0 ;
2065- else if (mer == PM && tm -> tm_hour != 12 )
2066- tm -> tm_hour += 12 ;
2065+ else if (mer == PM && tm -> tm_hour != HOURS_PER_DAY / 2 )
2066+ tm -> tm_hour += HOURS_PER_DAY / 2 ;
20672067
2068- if (tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > 59 ||
2069- tm -> tm_sec < 0 || tm -> tm_sec > 60 || tm -> tm_hour > 24 ||
2068+ if (tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > MINS_PER_HOUR - 1 ||
2069+ tm -> tm_sec < 0 || tm -> tm_sec > SECS_PER_MINUTE ||
2070+ tm -> tm_hour > HOURS_PER_DAY ||
20702071/* test for > 24:00:00 */
2071- (tm -> tm_hour == 24 &&
2072+ (tm -> tm_hour == HOURS_PER_DAY &&
20722073 (tm -> tm_min > 0 || tm -> tm_sec > 0 || * fsec > 0 ))||
20732074#ifdef HAVE_INT64_TIMESTAMP
20742075* fsec < INT64CONST (0 )|| * fsec > USECS_PER_SEC
@@ -2396,13 +2397,15 @@ DecodeTime(char *str, int fmask, int range,
23962397
23972398/* do a sanity check */
23982399#ifdef HAVE_INT64_TIMESTAMP
2399- if (tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > 59 ||
2400- tm -> tm_sec < 0 || tm -> tm_sec > 60 || * fsec < INT64CONST (0 )||
2400+ if (tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > MINS_PER_HOUR - 1 ||
2401+ tm -> tm_sec < 0 || tm -> tm_sec > SECS_PER_MINUTE ||
2402+ * fsec < INT64CONST (0 )||
24012403* fsec > USECS_PER_SEC )
24022404return DTERR_FIELD_OVERFLOW ;
24032405#else
2404- if (tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > 59 ||
2405- tm -> tm_sec < 0 || tm -> tm_sec > 60 || * fsec < 0 || * fsec > 1 )
2406+ if (tm -> tm_hour < 0 || tm -> tm_min < 0 || tm -> tm_min > MINS_PER_HOUR - 1 ||
2407+ tm -> tm_sec < 0 || tm -> tm_sec > SECS_PER_MINUTE ||
2408+ * fsec < 0 || * fsec > 1 )
24062409return DTERR_FIELD_OVERFLOW ;
24072410#endif
24082411
@@ -2748,9 +2751,9 @@ DecodeTimezone(char *str, int *tzp)
27482751
27492752if (hr < 0 || hr > 14 )
27502753return DTERR_TZDISP_OVERFLOW ;
2751- if (min < 0 || min >=60 )
2754+ if (min < 0 || min >=MINS_PER_HOUR )
27522755return DTERR_TZDISP_OVERFLOW ;
2753- if (sec < 0 || sec >=60 )
2756+ if (sec < 0 || sec >=SECS_PER_MINUTE )
27542757return DTERR_TZDISP_OVERFLOW ;
27552758
27562759tz = (hr * MINS_PER_HOUR + min )* SECS_PER_MINUTE + sec ;
@@ -3324,7 +3327,7 @@ DecodeISO8601Interval(char *str,
33243327{
33253328case 'Y' :
33263329tm -> tm_year += val ;
3327- tm -> tm_mon += (fval * 12 );
3330+ tm -> tm_mon += (fval * MONTHS_PER_YEAR );
33283331break ;
33293332case 'M' :
33303333tm -> tm_mon += val ;
@@ -3359,7 +3362,7 @@ DecodeISO8601Interval(char *str,
33593362return DTERR_BAD_FORMAT ;
33603363
33613364tm -> tm_year += val ;
3362- tm -> tm_mon += (fval * 12 );
3365+ tm -> tm_mon += (fval * MONTHS_PER_YEAR );
33633366if (unit == '\0' )
33643367return 0 ;
33653368if (unit == 'T' )
@@ -4155,7 +4158,7 @@ InstallTimeZoneAbbrevs(tzEntry *abbrevs, int n)
41554158{
41564159strncpy (newtbl [i ].token ,abbrevs [i ].abbrev ,TOKMAXLEN );
41574160newtbl [i ].type = abbrevs [i ].is_dst ?DTZ :TZ ;
4158- TOVAL (& newtbl [i ],abbrevs [i ].offset /60 );
4161+ TOVAL (& newtbl [i ],abbrevs [i ].offset /MINS_PER_HOUR );
41594162}
41604163
41614164/* Check the ordering, if testing */