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: 9 months ago
JSON representation
Provides helpers for quick formatting of dates and numbers. Integration of moment (with languages) and numeral (with languages too).
- Host: GitHub
- URL: https://github.com/djhi/meteor-formatting
- Owner: djhi
- Created: 2014-06-30T08:32:18.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-07-10T18:28:13.000Z (over 11 years ago)
- Last Synced: 2024-12-30T21:43:54.143Z (10 months ago)
- Language: JavaScript
- Size: 188 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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}}
```