[BACK]Return to day.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / calendar

Diff for /src/usr.bin/calendar/day.c between version 1.13 and 1.17

version 1.13, 2001/09/27 18:19:20 version 1.17, 2004/12/10 15:31:01
Line 12 
Line 12 
  * 2. Redistributions in binary form must reproduce the above copyright   * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the   *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.   *    documentation and/or other materials provided with the distribution.
  * 3. All advertising materials mentioning features or use of this software   * 3. Neither the name of the University nor the names of its contributors
  *    must display the following acknowledgement:  
  *      This product includes software developed by the University of  
  *      California, Berkeley and its contributors.  
  * 4. Neither the name of the University nor the names of its contributors  
  *    may be used to endorse or promote products derived from this software   *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.   *    without specific prior written permission.
  *   *
Line 43 
Line 39 
 #if 0  #if 0
 static const char sccsid[] = "@(#)calendar.c  8.3 (Berkeley) 3/25/94";  static const char sccsid[] = "@(#)calendar.c  8.3 (Berkeley) 3/25/94";
 #else  #else
 static char rcsid[] = "$OpenBSD$";  static const char rcsid[] = "$OpenBSD$";
 #endif  #endif
 #endif /* not lint */  #endif /* not lint */
   
Line 69 
Line 65 
 struct tm *tp;  struct tm *tp;
 int *cumdays, offset;  int *cumdays, offset;
 char dayname[10];  char dayname[10];
   enum calendars calendar;
   u_long julian;
   
   
 /* 1-based month, 0-based days, cumulative */  /* 1-based month, 0-based days, cumulative */
Line 242 
Line 240 
     return(mktime(&tm));      return(mktime(&tm));
 }  }
   
   void
   adjust_calendar(int *day, int *month)
   {
           switch (calendar) {
           case GREGORIAN:
                   break;
   
           case JULIAN:
                   *day += julian;
                   if (*day > (cumdays[*month + 1] - cumdays[*month])) {
                           *day -= (cumdays[*month + 1] - cumdays[*month]);
                           if (++*month > 12)
                                   *month = 1;
                   }
                   break;
           case LUNAR:
                   break;
           }
   }
   
 /*  /*
  * Possible date formats include any combination of:   * Possible date formats include any combination of:
  *      3-charmonth                     (January, Jan, Jan)   *      3-charmonth                     (January, Jan, Jan)
Line 316 
Line 334 
                 if (month == -1) {                  if (month == -1) {
                         month = tp->tm_mon + 1;                          month = tp->tm_mon + 1;
                         interval = MONTHLY;                          interval = MONTHLY;
                 }                  } else if (calendar)
                           adjust_calendar(&day, &month);
                 if ((month > 12) || (month < 1))                  if ((month > 12) || (month < 1))
                         return (NULL);                          return (NULL);
         }          }
Line 334 
Line 353 
                         day = 1;                          day = 1;
                 /* If a weekday was spelled out without an ordering,                  /* If a weekday was spelled out without an ordering,
                  * assume the first of that day in the month */                   * assume the first of that day in the month */
                 if ((flags & F_ISDAY) && (day >= 1) && (day <=7))                  if ((flags & F_ISDAY)) {
                         day += 10;                          if ((day >= 1) && (day <=7))
                                   day += 10;
                   } else if (calendar)
                           adjust_calendar(&day, &month);
         }          }
   
         /* Hm ... */          /* Hm ... */
Line 352 
Line 374 
                         if (month == -1) {                          if (month == -1) {
                                 month = tp->tm_mon + 1;                                  month = tp->tm_mon + 1;
                                 interval = MONTHLY;                                  interval = MONTHLY;
                         }                          } else if (calendar)
                                   adjust_calendar(&day, &month);
                 }                  }
   
                 /* {Month} {Weekday,Day} ...  */                  /* {Month} {Weekday,Day} ...  */
Line 361 
Line 384 
                         month = v1;                          month = v1;
                         /* if no recognizable day, assume the first */                          /* if no recognizable day, assume the first */
                         day = v2 ? v2 : 1;                          day = v2 ? v2 : 1;
                         if ((flags & F_ISDAY) && (day >= 1) && (day <= 7))                          if ((flags & F_ISDAY)) {
                                 day += 10;                                  if ((day >= 1) && (day <= 7))
                                           day += 10;
                           } else
                                   adjust_calendar(&day, &month);
                 }                  }
         }          }
   
Line 454 
Line 480 
                         tmp->next  = NULL;                          tmp->next  = NULL;
                         return(tmp);                          return(tmp);
                 }                  }
         }          } else {
         else {  
                 varp = 1;                  varp = 1;
                 /* Set up v1 to the event number and ... */                  /* Set up v1 to the event number and ... */
                 v1 = vwd % (NUMEV + 1) - 1;                  v1 = vwd % (NUMEV + 1) - 1;
Line 565 
Line 590 
   
 int  int
 getmonth(s)  getmonth(s)
         register char *s;          char *s;
 {  {
         register char **p;          char **p;
         struct fixs *n;          struct fixs *n;
   
         for (n = fnmonths; n->name; ++n)          for (n = fnmonths; n->name; ++n)
Line 585 
Line 610 
   
 int  int
 getday(s)  getday(s)
         register char *s;          char *s;
 {  {
         register char **p;          char **p;
         struct fixs *n;          struct fixs *n;
   
         for (n = fndays; n->name; ++n)          for (n = fndays; n->name; ++n)
Line 609 
Line 634 
  */   */
 int  int
 getdayvar(s)  getdayvar(s)
         register char *s;          char *s;
 {  {
         register int offset;          int offset;
   
   
         offset = strlen(s);          offset = strlen(s);

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.17