Handlebars Helpers
Sugartime
Save a date using sugartime syntax
Overview
This helper outputs a date in a specified format according to the human time explanation.
It uses the Sugar.js Date library to parse the human date text.
You can use the interactive tool the this page to test the human date text.
The format uses the moment.js format.
When concatenating more than one human time phrase, ensure each phrase is separated by a coma.
Concatenating
Concatenating, stringing more that one phrase together, allows you to do quite complex sugartime calculations.
It calculates working from left to right, starting with the left most phrase. The result of the first phrase calculation is used as the starting point for the 2 second phrase calculation. It will continue until there is nothing left to calculate.
Sugartime human syntax is not an LLM, you cannot ask it to do complex calculations like "the first Monday of next month", it will not understand that. You can however use the concatenation to build up a date from smaller parts, like "next month, the first Monday".
You should split up complex calculations into smaller parts and concatenate them together.
Syntax
Examples
Basic Example
Basic example will output the date in default format "YYYY-MM-DD HH:mm:SS" according to the human time explanation.
Usage
Substitution
Concat Example
Concat example will output the date in default format "YYYY-MM-DD HH:mm:SS" according to the human time explanation that is given in parts
Usage
Substitution
Format Example
Format example will output the date in a specified format "YYYY-MM-DD".
Usage
Substitution
Concat nudging example
Concat example will output the date in default format by nudging in parts
Usage
Substitution