X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom%2Fdate.c;h=a4853925294f2424f083aec639c152096fd51fc3;hb=72bf48ecdfeb265665a04fc29f8703902bc296ed;hp=4f61ccabbeace3c45f69f80671efc789203e12ad;hpb=359ac00a8a5a1d69804380ff5c97c3d01036d1a9;p=gedcom-parse.git diff --git a/gedcom/date.c b/gedcom/date.c index 4f61cca..a485392 100644 --- a/gedcom/date.c +++ b/gedcom/date.c @@ -336,7 +336,7 @@ int numbers_to_strings(struct date *d) if (d->day != -1) sprintf(d->day_str, "%d", d->day); - if (d->month != -1) + if (d->month > 0 && d->month <= max_month[d->cal]) strcpy(d->month_str, month_name[d->cal][d->month - 1]); if (d->year_type == YEAR_SINGLE) @@ -383,7 +383,7 @@ int gedcom_normalize_date(Date_input input, struct date_value *val) return result; } -struct date_value* gedcom_new_date_value(struct date_value* copy_from) +struct date_value* gedcom_new_date_value(const struct date_value* copy_from) { struct date_value* dv_ptr; dv_ptr = (struct date_value*) malloc(sizeof(struct date_value)); @@ -429,7 +429,7 @@ struct date_value gedcom_parse_date(const char* line_value) return dv_s; } -void write_date(struct date* d) +void write_date(const struct date* d) { if (! d->year_str[0] || d->year <= 0 || d->sdn1 <= 0) gedcom_error(_("Date is not normalized: some fields are invalid")); @@ -455,7 +455,7 @@ void write_date(struct date* d) } } -char* gedcom_date_to_string(struct date_value* val) +char* gedcom_date_to_string(const struct date_value* val) { init_buffer(&date_buffer); reset_buffer(&date_buffer);