< previous page page_222 next page >

Page 222
Listing 8.14 iso_ywd_to_date ()
/* iywd2dat.c


   +------------------------------------------+
   |   Copyright (C) 1995 by Lance W. Latham. |
   |         All rights reserved.             |
   +------------------------------------------+


   Routine converts a date expressed as an ISO_YWD structure of a year, week and
   day 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.


   INPUTS:
   1. ywd, pointer to an ISO_YWD structure, containing the date to be
      converted to a DATE_INFO structure date.


   OUTPUTS:
   1. Returned by routine, a DATE_INFO structure containing the input date,
      converted to DATE_INFO form.


   NOTES:
   1. The 'week' of the ISO_YWD structure is the ISO week number, 1 to 53.
   2. The 'day' of the ISO_YWD structure is the ISO day number in a week,
      from 1 to 7, as follows:
      1 = Monday
      2 = Tuesday
      3 = Wednesday
      4 = Thursday
      5 = Friday
      6 = Saturday
      7 = Sunday
*/


#include "scdtl_2.h"
#include "iso_2.h"
struct DATE_INFO iso_ywd_to_date (struct ISO_YWD *ywd)
{
   double jd;
   struct DATE_INFO date;


   date = iso_first_day_of_week (ywd->year, ywd->week);
   jd = date_to_JD0 (&date);
   jd += (double) (ywd->day - 1);
   date = JD0_to_date (jd);


   return (date);
}




 
< previous page page_222 next page >