From 5e408184a0a07cb8b3a774606c237997b697264c Mon Sep 17 00:00:00 2001 From: Diego Fernandez Date: Wed, 14 Aug 2019 16:46:22 +0100 Subject: [PATCH] docs: update the README --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index 7da0d04..4c7b7d5 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,26 @@ Parses a custom-formatted date into a moment object that can be used with the ot Prints `Last updated: January 24, 2016` +The pipe can also accept an array of formats as parameter. + +``` typescript +@Component({ + selector: 'app', + template: ` + Last updated: {{'24/01/2014 22:00' | amParse: formats | amDateFormat:'LL'}} + ` +}) +export class App { + + formats: ['DD/MM/YYYY HH:mm:ss', 'DD/MM/2016 HH:mm']; + + constructor() { } + +} +``` + +Prints `Last updated: January 24, 2016` + ## amLocal pipe Converts UTC time to local time. @@ -291,6 +311,37 @@ Parses the date as UTC and enables mode for subsequent moment operations (such a Prints `Last updated: 2017-01-01` +It's also possible to specify a different format than the standard ISO8601. + +``` typescript +@Component({ + selector: 'app', + template: ` + Last updated: {{ '31/12/2016 23:00-01:00' | amFromUtc: 'DD/MM/2016 HH:mmZZ' | amDateFormat: 'YYYY-MM-DD' }} + ` +}) +``` + +Or even an array of formats: + +``` typescript +@Component({ + selector: 'app', + template: ` + Last updated: {{ '31/12/2016 23:00-01:00' | amFromUtc: formats | amDateFormat: 'YYYY-MM-DD' }} + ` +}) +export class App { + + formats: ['DD/MM/YYYY HH:mm:ss', 'DD/MM/2016 HH:mmZZ']; + + constructor() { } + +} +``` + +Both examples above will print `Last updated: 2017-01-01` + ## amUtc pipe Enables UTC mode for subsequent moment operations (such as displaying the time in UTC).