[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.15 and 1.16

version 1.15, 2003/06/03 02:56:06 version 1.16, 2004/12/10 15:00:27
Line 65 
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 238 
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 312 
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 330 
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 348 
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 357 
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 450 
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;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16