Further WIP

This commit is contained in:
Laurence Withers 2006-10-15 18:37:34 +01:00
parent 106f60b5c0
commit fdd856381d
2 changed files with 50 additions and 0 deletions

View File

@ -295,6 +295,31 @@ int iso8601_from_cal(struct iso8601_date* date, int year, int month, int day)
int iso8601_from_ord(struct iso8601_date* date, int year, int oday)
{
// check for domain errors
if(oday < 1 || oday > (iso8601_isleap(year) ? 366 : 365)) {
errno = EDOM;
return -1;
}
// perform year calculation
if(_from_year(date, year)) return -1;
// now simply add number of days elapsed this year
date->day += oday - 1;
return 0;
}
int iso8601_from_week(struct iso8601_date* date, int isoyear, int week, int wday)
{
}
/* options for text editors
kate: replace-trailing-space-save true; space-indent true; tab-width 4;
vim: expandtab:ts=4:sw=4

View File

@ -142,6 +142,28 @@ void do_details_ordinal(struct iso8601_details* dt_out, const struct iso8601_det
dt_out->date_prec = iso8601_prec_ord;
}
void do_details_week(struct iso8601_details* dt_out, const struct iso8601_details* dt_in)
{
memcpy(dt_out, dt_in, sizeof(struct iso8601_details));
dt_out->tz_sec = 0;
dt_out->date_prec = iso8601_prec_week;
}
void do_details_week_day(struct iso8601_details* dt_out, const struct iso8601_details* dt_in)
{
memcpy(dt_out, dt_in, sizeof(struct iso8601_details));
dt_out->tz_sec = 0;
dt_out->date_prec = iso8601_prec_wday;
dt_out->time_prec = iso8601_prec_none;
}
void do_details_week_full(struct iso8601_details* dt_out, const struct iso8601_details* dt_in)
{
memcpy(dt_out, dt_in, sizeof(struct iso8601_details));
dt_out->tz_sec = 0;
dt_out->date_prec = iso8601_prec_wday;
}
struct test {
@ -169,6 +191,9 @@ const struct test tests[] = {
{ "Local year", do_details_local_year },
{ "Ordinal date", do_details_ordinal_date },
{ "Ordinal full", do_details_ordinal },
{ "Week number", do_details_week },
{ "Week date", do_details_week_day },
{ "Week full", do_details_week_full },
{ 0, 0 }
};