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

coda

v1.1.1 Public

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

Dependencies (1)


Dev Dependencies (2)


v1.1.1

01 Sep 2021 — 03:03: 52 UTC

docs

  • README: Add new locale - de_DE (5a7f6b8)

 

$ box install coda

No collaborators yet.
     
  • {{ getFullDate("Sep 01 2021 03:09 AM GMT") }}
  • {{ getFullDate("Sep 01 2021 03:09 AM GMT") }}
  • 482
  • 0
  • 78