fixing bug in date calculation for JSON output