date@1.0.0

date@1.0.0

Component which defines simple API methods to format dates according to aliases.

By @mantradev
Depends on apiextend

Install with:

$ mantrad download-component date@1.0.0

Or install last version with:

$ mantrad download-component date

README.md

date Mantra component

This simple component adds some API to manage the formatting of dates. In the configuration of the components should be placed some alias for the formats to use.

The component tries to simplify and unify the formatting of the dates within the whole application.

API Mantra.api.date.format( Mantra, params )

Returns a date object in a string format according with the alias indicated.

params is an object with these values:

  • date : <date object to format>
  • format : <string, indicating the type of format to return according to component configuration, default 'F1'>

API Mantra.API.DATA.formatbyproperty( Mantra, params )

Iterates of a date property of an array and formats its according to format.

params is an object with these values:

  • entity : <array with entities to iterate over>,
  • property : <name of the property>,
  • format : <string, indicating the type of format to return according to component configuration, default 'F1'>

date configuration params

The configuration of the component that can be overrided by the aplication includes the aliases for the formatting, like this:

{
    "F1": "DD-MM-YYYY HH:mm:ss",
    "F2": "DD-MMM-YYYY"
}