add_assoc_long(return_value, "year", year);
/* day of week */
- dow = DayOfWeek(jd);
- add_assoc_long(return_value, "dow", dow);
- add_assoc_string(return_value, "abbrevdayname", DayNameShort[dow], 1);
- add_assoc_string(return_value, "dayname", DayNameLong[dow], 1);
+ if (cal != CAL_JEWISH || year > 0) {
+ dow = DayOfWeek(jd);
+ add_assoc_long(return_value, "dow", dow);
+ add_assoc_string(return_value, "abbrevdayname", DayNameShort[dow], 1);
+ add_assoc_string(return_value, "dayname", DayNameLong[dow], 1);
+ } else {
+ add_assoc_null(return_value, "dow");
+ add_assoc_string(return_value, "abbrevdayname", "", 1);
+ add_assoc_string(return_value, "dayname", "", 1);
+ }
/* month name */
if(cal == CAL_JEWISH) {
/* special case for Jewish calendar */
- add_assoc_string(return_value, "abbrevmonth", JEWISH_MONTH_NAME(year)[month], 1);
- add_assoc_string(return_value, "monthname", JEWISH_MONTH_NAME(year)[month], 1);
+ add_assoc_string(return_value, "abbrevmonth", (year > 0 ? JEWISH_MONTH_NAME(year)[month] : ""), 1);
+ add_assoc_string(return_value, "monthname", (year > 0 ? JEWISH_MONTH_NAME(year)[month] : ""), 1);
} else {
add_assoc_string(return_value, "abbrevmonth", calendar->month_name_short[month], 1);
add_assoc_string(return_value, "monthname", calendar->month_name_long[month], 1);
break;
case CAL_MONTH_JEWISH: /* jewish month */
SdnToJewish(julday, &year, &month, &day);
- monthname = JEWISH_MONTH_NAME(year)[month];
+ monthname = (year > 0 ? JEWISH_MONTH_NAME(year)[month] : "");
break;
case CAL_MONTH_FRENCH: /* french month */
SdnToFrench(julday, &year, &month, &day);