Skip to main content

DateTime Widget

Provides Handlebars helpers for formatting dates with timezone support. Unlike the other widgets, DateTime does not register a partial. It only registers helpers.

Usage

In your index.ts:

import "../../widgets/date-time";

In your template.hbs, call the helpers directly:

<p>Invoice Date: {{formateShortDateWithOffset invoiceDateUserInput ownerOffset}}</p>
<p>Due Date: {{formateShortDateWithOffset formattedDueDate ownerOffset}}</p>

Available helpers

formateShortDateWithOffset

Formats a date using a short format (like "01 Sep 2025") with a timezone offset.

{{formateShortDateWithOffset dateValue timezoneOffset}}

Parameters:

  • dateValue is the date string from the API
  • timezoneOffset is the timezone offset in minutes (like 330 for IST)

formateDateWithOffset

Same as above but uses a longer date format.

{{formateDateWithOffset dateValue timezoneOffset}}

formatDateInTimeZone

Formats a date string in a specific named timezone.

{{formatDateInTimeZone dateValue "UTC" "SECONDARY_SHORT_DATE_FORMAT"}}

Parameters:

  • dateValue is the date string
  • Second argument is the timezone name (like "UTC", "Asia/Kolkata")
  • Third argument is the format name

formatDateAddDays

Adds a number of days to a date then formats it.

{{formatDateAddDays dueDate 30 ownerOffset}}

Useful for showing "payment due in 30 days from invoice date".

Why not just use Moment.js or dayjs?

Ceres templates run in the browser and need to be small. The DateTime widget uses lightweight formatting functions that handle the specific date patterns Refrens needs, without pulling in a full date library.