Changeset: 935220fa9232 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=935220fa9232 Modified Files: monetdb5/modules/atoms/mtime.c monetdb5/modules/atoms/mtime.h monetdb5/modules/atoms/mtime.mal Branch: default Log Message:
merged with Oct2014 diffs (83 lines): diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c --- a/monetdb5/modules/atoms/mtime.c +++ b/monetdb5/modules/atoms/mtime.c @@ -2386,6 +2386,21 @@ MTIMEtimestamp_add_month_interval_wrap(t } str +MTIMEtimestamp_add_month_interval_lng_wrap(timestamp *ret, const timestamp *v, const lng *months) +{ + daytime t; + date d; + int m; + MTIMEtimestamp_extract_daytime(&t, v, &tzone_local); + MTIMEtimestamp_extract_date(&d, v, &tzone_local); + if (*months > (YEAR_MAX*12)) + throw(MAL, "mtime.timestamp_sub_interval", "to many months"); + m = (int)*months; + MTIMEdate_addmonths(&d, &d, &m); + return MTIMEtimestamp_create(ret, &d, &t, &tzone_local); +} + +str MTIMEtimestamp_sub_month_interval_wrap(timestamp *ret, const timestamp *v, const int *months) { daytime t; @@ -2398,6 +2413,22 @@ MTIMEtimestamp_sub_month_interval_wrap(t } str +MTIMEtimestamp_sub_month_interval_lng_wrap(timestamp *ret, const timestamp *v, const lng *months) +{ + daytime t; + date d; + int m; + MTIMEtimestamp_extract_daytime(&t, v, &tzone_local); + MTIMEtimestamp_extract_date(&d, v, &tzone_local); + if (*months > (YEAR_MAX*12)) + throw(MAL, "mtime.timestamp_sub_interval", "to many months"); + m = -(int)*months; + MTIMEdate_addmonths(&d, &d, &m); + return MTIMEtimestamp_create(ret, &d, &t, &tzone_local); +} + + +str MTIMEtime_add_msec_interval_wrap(daytime *ret, const daytime *t, const lng *mseconds) { lng s = *mseconds; diff --git a/monetdb5/modules/atoms/mtime.h b/monetdb5/modules/atoms/mtime.h --- a/monetdb5/modules/atoms/mtime.h +++ b/monetdb5/modules/atoms/mtime.h @@ -220,6 +220,8 @@ mtime_export str MTIMEdate_add_msec_inte mtime_export str MTIMEtimestamp_sub_msec_interval_lng_wrap(timestamp *ret, const timestamp *t, const lng *msec); mtime_export str MTIMEtimestamp_sub_month_interval_wrap(timestamp *ret, const timestamp *t, const int *months); mtime_export str MTIMEtimestamp_add_month_interval_wrap(timestamp *ret, const timestamp *t, const int *months); +mtime_export str MTIMEtimestamp_sub_month_interval_lng_wrap(timestamp *ret, const timestamp *t, const lng *months); +mtime_export str MTIMEtimestamp_add_month_interval_lng_wrap(timestamp *ret, const timestamp *t, const lng *months); mtime_export str MTIMEtime_sub_msec_interval_wrap(daytime *ret, const daytime *t, const lng *msec); mtime_export str MTIMEtime_add_msec_interval_wrap(daytime *ret, const daytime *t, const lng *msec); mtime_export str MTIMEcompute_rule_foryear(date *ret, const rule *val, const int *year); diff --git a/monetdb5/modules/atoms/mtime.mal b/monetdb5/modules/atoms/mtime.mal --- a/monetdb5/modules/atoms/mtime.mal +++ b/monetdb5/modules/atoms/mtime.mal @@ -397,9 +397,19 @@ address MTIMEtimestamp_add; command timestamp_sub_month_interval(t:timestamp,s:int):timestamp address MTIMEtimestamp_sub_month_interval_wrap comment "Subtract months from a timestamp"; + +command timestamp_sub_month_interval(t:timestamp,s:lng):timestamp +address MTIMEtimestamp_sub_month_interval_lng_wrap +comment "Subtract months from a timestamp"; + command timestamp_add_month_interval(t:timestamp,s:int):timestamp address MTIMEtimestamp_add_month_interval_wrap comment "Add months to a timestamp"; + +command timestamp_add_month_interval(t:timestamp,s:lng):timestamp +address MTIMEtimestamp_add_month_interval_lng_wrap +comment "Add months to a timestamp"; + command timestamp(t:timestamp):timestamp address MTIMEtimestamp2timestamp; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list