diff options
Diffstat (limited to 'sql/date.c')
| -rw-r--r-- | sql/date.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -57,9 +57,9 @@ static inline TDate TDate_from_DateADT(DateADT d) { } static inline const char* cal_from_currency(const char* curr) { - const char default_cal[] = "NONE"; - const char us_cal[] = "/usr/share/cds/US"; - if (strcmp(currency, "USD") == 0) { + static const char default_cal[] = "NONE"; + static const char us_cal[] = "/usr/share/cds/US"; + if (strcmp(curr, "USD") == 0) { return us_cal; } else { return default_cal; @@ -68,8 +68,6 @@ static inline const char* cal_from_currency(const char* curr) { 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"; DateADT d = PG_GETARG_DATEADT(0); float8 coupon = PG_GETARG_FLOAT8(1); bool include_cashflow = PG_GETARG_BOOL(2); @@ -77,9 +75,9 @@ Datum cds_accrued(PG_FUNCTION_ARGS) { const char* cal = cal_from_currency(currency); 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"); - } + if (date1 == -1) + elog(ERROR, "Please set up the US calendar in /usr/share/cds/US"); + TDate date_prev = _previous_twentieth(date1, true, cal); if ((date_prev == date) && include_cashflow) { |
