Skip to content

Commit 649ccb8

Browse files
authored
Merge pull request #58 from brockpetrie/unix-time
Treat Number input as Unix time
2 parents 08c474a + 1f6aede commit 649ccb8

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-moment",
3-
"version": "3.0.0",
3+
"version": "3.1.0",
44
"description": "Handy Moment.js filters for your Vue.js project",
55
"main": "vue-moment.js",
66
"scripts": {

readme.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ Handy [Moment.js](http://www.momentjs.com) filters for your [Vue.js](http://vuej
55

66
## Installation
77

8-
Install via NPM and
8+
Install via NPM...
99

1010
```sh
1111
$ npm install vue-moment
1212
```
1313

14-
Require the plugin like so:
14+
...and require the plugin like so:
1515

1616
```js
1717
Vue.use(require('vue-moment'));
@@ -29,7 +29,7 @@ Simply set `moment` as the filtering function and you're good to go. At least on
2929

3030
## Passing Your Date
3131

32-
Moment.js expects your input to be either: a valid ISO 8601 formatted string (see <http://momentjs.com/docs/#/parsing/string/>), a valid `Date` object, or a date string with an accompanying format pattern (i.e. when you know the format of the date input). For the latter, `vue-moment` allows you to pass your date and format pattern(s) as an array, like such:
32+
Moment.js expects your input to be either: a valid ISO 8601 formatted string (see <http://momentjs.com/docs/#/parsing/string/>), a valid `Date` object, a Unix timestamp (must be passed as a Number), or a date string with an accompanying format pattern (i.e. when you know the format of the date input). For the latter, `vue-moment` allows you to pass your date and format pattern(s) as an array, like such:
3333

3434
```html
3535
<span>{{ [ someDate, "MM.DD.YY" ] | moment("dddd, MMMM Do YYYY") }}</span>

vue-moment.js

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ module.exports = {
2626
// Format pattern will accept an array of potential formats to parse against.
2727
// Date string should be at [0], format pattern(s) should be at [1]
2828
date = moment(string = input[0], formats = input[1], true);
29+
} else if (typeof input === 'number') {
30+
// If input is an integer, assume it's a Unix timestamp.
31+
date = moment.unix(input);
2932
} else {
3033
// Otherwise, throw the input at moment and see what happens...
3134
date = moment(input);

0 commit comments

Comments
 (0)