Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/djhi/meteor-formatting

Provides helpers for quick formatting of dates and numbers. Integration of moment (with languages) and numeral (with languages too).
https://github.com/djhi/meteor-formatting

Last synced: 23 days ago
JSON representation

Provides helpers for quick formatting of dates and numbers. Integration of moment (with languages) and numeral (with languages too).

Awesome Lists containing this project

README

        

meteor-formatting
=================

Provides helpers for quick formatting of dates and numbers. Integration of moment (with languages) and numeral (with languages too).

# Dates Helpers

## duration
Ouput the result of `moment().duration`.

**parameters**

* `duration`: the duration (example: `10`)
* `units`: units used for the duration (default is `hours`)

**usage**
``` handlebars
{{duration 10 'days'}}
```

## fromNow
Ouput the result of `moment.fromNow`.

**parameters**

* `date`: the date (example: `01/01/2014`)

**usage**
``` handlebars
{{fromNow myDate}}
```

## formatDate
Ouput the result of `moment.format`.

**parameters**

* `date`: the date (example: `01/01/2014`)
* `format`: format used (default is `DD/MM/YYYY`)

**usage**
``` handlebars
{{formatDate myDate}}
```

## mediumDate
Ouput the result of `moment.format('LL')`.

**parameters**

* `date`: the date (example: `01/01/2014`)

**usage**
``` handlebars
{{mediumDate myDate}}
```

## month
Ouput the result of `moment.format('MMMM')` (Ouput the full month's name)

**parameters**

* `date`: the date (example: `01/01/2014`)

**usage**
``` handlebars
{{month myDate}}
```

## shortMonthAndYear
Ouput the result of `moment.format('MM YYYY')` (Ouput the short month's name and the year)

**parameters**

* `date`: the date (example: `01/01/2014`)

**usage**
``` handlebars
{{shortMonthAndYear myDate}}
```
# Numbers Helpers

## currency
Ouput the result of `numeral().format('$0.00')` or `numeral().format('0.00$')`.

**parameters**

* `number`: the number to format (example: `10`)
* `symbolAtEnd`: wether to show the currency symbol at the end (default is `false`)

**usage**
``` handlebars
{{currency 10}}
```
``` handlebars
{{currency 10 true}}
```

## percentage
Ouput the result of `numeral().format('0%')`.

**parameters**

* `number`: the number to format (example: `10`). If this number is greater than 1, it will be divided by 100 as numeral expect a number lesser than 1.

**usage**
``` handlebars
{{percentage 10}}
```