aboutsummaryrefslogtreecommitdiffstats
path: root/sql/date.c
diff options
context:
space:
mode:
Diffstat (limited to 'sql/date.c')
-rw-r--r--sql/date.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/sql/date.c b/sql/date.c
index aa81342c..b64e095b 100644
--- a/sql/date.c
+++ b/sql/date.c
@@ -49,10 +49,15 @@ TDate _previous_twentieth(TDate d, bool roll, const char* cal) {
}
}
-PG_FUNCTION_INFO_V1(cds_accrued);
-
// postgresql represents dates as number of days since 2000-01-01
// TDate are integers since 1601-01-01
+static inline TDate TDate_from_DateADT(DateADT d) {
+ return d + 145731;
+}
+
+PG_FUNCTION_INFO_V1(cds_accrued);
+
+
Datum cds_accrued(PG_FUNCTION_ARGS) {
const char default_cal[] = "NONE";
const char us_cal[] = "/usr/share/cds/US";
@@ -67,7 +72,7 @@ Datum cds_accrued(PG_FUNCTION_ARGS) {
} else {
cal = default_cal;
}
- TDate date = d + 145731 + 1;
+ TDate date = TDate_from_DateADT(d) + 1;
TDate date1 = next_business_day(date, JPMCDS_BAD_DAY_PREVIOUS, cal);
if (date1 == -1) {
elog(ERROR, "Please set up the US calendar in /usr/share/cds/US");