Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
feat(*): preprocessors, custom input format and timezone become filters
Browse files Browse the repository at this point in the history
close #174

BREAKING CHANGE:

Preprocessors, timezones and input format were removed from am-time-ago and all filters. Use the new `amFromUnix`,
`amUtc`, `amUtcOffset`, `amTimezone`, and `amParse` filters instead.

Examples:
* `<time am-time-ago="myDate" am-format="YYYY-MM-DD">` becomes `<time am-time-ago="myDate|amParse:'YYYY-MM-DD'">`
* `<time am-time-ago="myDate" am-preprocess="unix">` becomes `<time am-time-ago="myDate|amFromUnix">`
* `{{myDate|amCalendar:'unix'}}` becomes `{{myDate|amFromUnix|amCalendar}}`
* `{{myDate|amCalendar:null:'PDT'}}` becomes `{{myDate|amTimezone:'PDT'|amCalendar}}`

The removal of the preprocessors also affects the other positional parameters of the `amTimeAgo`:

`{{myDate|amTimeAgo:null:true:fromDate}}` becomes `{{myDate|amTimeAgo:true:fromDate}}`.
  • Loading branch information
urish committed Sep 13, 2015
1 parent 5bb7763 commit 4f3010b
Show file tree
Hide file tree
Showing 6 changed files with 296 additions and 289 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 0.11.0 - TBD

!!! BREAKING CHANGE !!!

Preprocessors, timezones and input format were removed from am-time-ago and all filters. Use the new `amFromUnix`,
`amUtc`, `amUtcOffset`, `amTimezone`, and `amParse` filters instead.

Examples:
* `<time am-time-ago="myDate" am-format="YYYY-MM-DD">` becomes `<time am-time-ago="myDate|amParse:'YYYY-MM-DD'">`
* `<time am-time-ago="myDate" am-preprocess="unix">` becomes `<time am-time-ago="myDate|amFromUnix">`
* `{{myDate|amCalendar:'unix'}}` becomes `{{myDate|amFromUnix|amCalendar}}`
* `{{myDate|amCalendar:null:'PDT'}}` becomes `{{myDate|amTimezone:'PDT'|amCalendar}}`

The removal of the preprocessors also affects the other positional parameters of the `amTimeAgo`:

`{{myDate|amTimeAgo:null:true:fromDate}}` becomes `{{myDate|amTimeAgo:true:fromDate}}`.

For more information, please see [#174](https://github.com/urish/angular-moment/issues/174);

## 0.10.3 - 2015-09-05
- Allow `amDateFormat` to work with custom formatted input date strings ([#162](https://github.com/urish/angular-moment/pull/162), contributed by [jblashka](https://github.com/jblashka))
- `amAdd`, `amSubtract` - add/subtract a value from a given date ([#171](https://github.com/urish/angular-moment/pull/171), contributed by [nicholasruggeri](https://github.com/nicholasruggeri))
Expand Down
32 changes: 20 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,11 @@ myapp.run(function(amMoment) {
});
```

### Configuration

Parameter `preprocess`(e.g: `unix`, `utc`) would pre-execute before.

```js
angular.module('myapp').constant('angularMomentConfig', {
preprocess: 'unix', // optional
timezone: 'Europe/London' // optional
});
```

### Timeago directive
Use am-time-ago directive to format your relative timestamps. For example:

```html
<span am-time-ago="message.time"></span>
<span am-time-ago="message.time" am-preprocess="unix"></span>
```

angular-moment will dynamically update the span to indicate how much time
Expand Down Expand Up @@ -157,6 +145,26 @@ Example:

```

### amParse

TODO add docs before 0.11.0 release

### amFromUnix

TODO add docs before 0.11.0 release

### amUtc

TODO add docs before 0.11.0 release

### amUtcOffset

TODO add docs before 0.11.0 release

### amTimezone

TODO add docs before 0.11.0 release

### Time zone support

The `amDateFormat` and `amCalendar` filters can be configured to display dates aligned
Expand Down
Loading

0 comments on commit 4f3010b

Please sign in to comment.