|
|
|
|
|
|
|
This section contains the SCDTL utility routines that specifically address the ISO usage of the week unit. |
|
|
|
|
|
|
|
|
The ISO week is used much more extensively in Europe than in the United States. Weekly magazine issues are numbered by week number, photographic film and many other consumables are identified by week number, factory deliveries are scheduled by week number, bus tickets are identified by week number, and so on. |
|
|
|
|
|
|
|
|
American programmers preparing software for an international market should prepare to master the intricacies of the ISO week. |
|
|
|
|
| Listing 8.9 | |
|
|
|
|
#include "scdtl_2.h"
#include "iso_2.h"
struct ISO_PERIOD iso_duration_and_end_to_period
(struct ISO_DURATION *duration, struct ISO_DATE_TIME *end)
{
double jdb, jde, jdd;
struct ISO_PERIOD p;
p.end = *end;
jde = iso_date_time_to_double (&(p.end));
p.duration = *duration;
if (p.duration.date.year < 0)
p.duration.date.year = -p.duration.date.year;
if (p.duration.date.month < 0)
p.duration.date.month = -p.duration.date.month;
if (p.duration.date.day < 0)
p.duration.date.day = -p.duration.date.day;
if (p.duration.time.hours < 0)
p.duration.time.hours = -p.duration.time.hours;
if (p.duration.time.minutes < 0)
p.duration.time.minutes = -p.duration.time.minutes;
if (p.duration.time.seconds < 0)
p.duration.time.seconds = -p.duration.time.seconds;
jdd = iso_duration_to_double (&(p.duration));
if (jdd < 0.0)
jdd = -jdd;
jdb = jde - jdd;
p.begin = iso_double_to_date_time (jdb);
return (p);
}
|
|
|
|
|
|
|
|