FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...

coda

v2.0.0 Modules

Coda

A collection of date helper functions

Methods

formatDistance

Returns the distance between two dates expressed as an approximate human-readable string.

NameTypeRequiredDefaultDescription
datedatetrue The date to calculate the distance.
baseDatedatefalsenow()The base date used to calculate the distance.
includeSecondsbooleanfalsefalseFlag to include different values for sub-minute times.
localestringfalseCurrent cbi18n locale.The locale to use for the distance.
coda.formatDistance( "2021-01-01 11:05: 23", "2021-01-01 10:00: 00" );
// "about an hour"

Internationalization

Coda supports the following locales:

  • en_US
  • de_DE

You can contribute a new locale by adding a file to the /resources/i18n/ folder. The file should be named coda_{LANG}(_{LOCALE}).json with _{LOCALE} being optional. cbi18n will use the most specific file found and fall back to more general files if not.

Additionally, please duplicate the FormatDistance_EN_US_Spec.cfc test and change the functions to return the correct translation for your new locale. This ensures we don't mess things up in the future.

Prior Art & Inspiration

v2.0.0

09 Feb 2024 — 04:16: 43 UTC

BREAKING

  • *: chore: Update dependencies and supported CFML versions (049ad9a)

fix

  • i18n: Add explicit en_US file (7832e99)

other

  • *: chore: Pin commandbox-semantic-release to ^3.0.0 (e8b0b20)

$ box install coda

No collaborators yet.
     
  • {{ getFullDate("2021-08-24T03:04:58Z") }}
  • {{ getFullDate("2024-02-09T04:16:45Z") }}
  • 2,090
  • 3,408