< previous page page_221 next page >

Page 221
8.4.5
ISO Year-Week-Day and Date
This section contains the SCDTL routines that interconvert the ISO_YWD and DATE_INFO structures. The ISO_YWD structure permits representation of dates using the ISO year-week-day format.
8.4.5.1
iso_date_to_ywd ()
This routine (Listing 8.13) converts a date expressed as a DATE_INFO structure, in a year, month, and day format, to an ISO_YWD structure, expressing the same date in the form of a year, week, and day. The week is the ISO week number, and the day is the ISO day in the week.
8.4.5.2
iso_ywd_to_date ()
This routine (Listing 8.14) converts a date expressed as an ISO_YWD structure, in a year, week, and day format, to a DATE_INFO structure, expressing the same date in the form of a year, month, and day. The week is the ISO week number, and the ISO_YWD day is the ISO day in the week.
(continued)
Listing 8.13
/*
   Following code checks for December dates which are part of the
   first week of the next year.
*/


   if (m == 12)
      {
      if (ywd.week == 1)
         ywd.year++;
      }


   jd = date_to_JD0 (date);
   ywd.day = day_of_week_index_JD0 (jd);


   if (ywd.day == 0)
      ywd.day = 7;


   return (ywd);
}



 
< previous page page_221 next page >