I would like to insert the time a draft was created into another draft. That part is working, but the hour seems to always be two digits. Ex: 8:15. I am formatting it like:
let contentTemplate =
-- + draft.processTemplate(“[[created|%l:%M %p]]”) + ': ’ +
I thought the %l would give the hour without a leading 0, but looks like it replaces the 0 with a space. Is there another way to format the hour as either 1 digit when the hour is between 1 and 9?
Sort of an oddity of Apple’s strftime implementation. I don’t think there’s a way to skip the padding space with strftime without trimming it out after formatting.
You can, however, use DateFormatter-based format strings that will not do that. Try this as your date tag:
More on the advanced date formatting options in the template docs.
However, that uses the current date / time. My use case is to use the Draft’s creation date / time. I’ll look at how to trip the output of
Sorry, just use
[[created|=h:mm a]] - all the date tags use the same format string options.