helpers / handlebars-helpers

188 handlebars helpers in ~20 categories. Can be used with Assemble, Ghost, YUI, express.js etc.
http://assemble.io/helpers/
MIT License
2.22k stars 364 forks source link

Issue with Date/moment helper for date with days above the 29th returns invalid date. #430

Open emmanuel-receeve opened 1 month ago

emmanuel-receeve commented 1 month ago

There is an issue with the date function handler in the handlesbar-helpers. It fails for all dates with days above the 29th (for example, 2024-06-30, 2024-07-31) return "invalid date". tested this here https://codesandbox.io/p/sandbox/dank-butterfly-j7dhfz

ahnennyi commented 2 weeks ago

There seems to be a bug in date library (version: 0.3.3) that is used for date parsing. For example, if you have handlebars template:

{{date dateVariable "DD.MM.YYYY, HH:mm:ss"}}

This will produce following results: dateVariable Result
2024-07-29 29.07.2024, 00:00:00
2024-07-30 Invalid date
2024-07-31 01.08.2024, 00:00:00
2024-07-32 30.09.2024, 20:24:00

You can disable date library by setting the parameter datejs=false:

{{date dateVariable "DD.MM.YYYY, HH:mm:ss" datejs=false}}

This will produce following results: dateVariable Result
2024-07-29 29.07.2024, 00:00:00
2024-07-30 30.07.2024, 00:00:00
2024-07-31 31.07.2024, 00:00:00
2024-07-32 Invalid date

Note that, in this case, new Date() will be used to parse the date string.