Skip to content

Commit

Permalink
Adding Intl.RelativeDateFormat example (#1245)
Browse files Browse the repository at this point in the history
* Adding  RelativeDateFormat example

* Updated code example

* fix wrong value
  • Loading branch information
romulocintra authored and wbamberg committed Dec 4, 2018
1 parent 24100f6 commit 4648996
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 82 deletions.
15 changes: 15 additions & 0 deletions live-examples/js-examples/intl/intl-relativetimeformat.html
@@ -0,0 +1,15 @@
<pre>
<code id="static-js">var rtf1 = new Intl.RelativeTimeFormat('en', { style: 'narrow' });

console.log(rtf1.format(3, 'quarter'));
//expected output: "in 3 qtrs."

console.log(rtf1.format(-1, 'day'));
//expected output: "1 day ago"

var rtf2 = new Intl.RelativeTimeFormat('es', { numeric: 'auto' });

console.log(rtf2.format(2, 'day'));
//expected output: "pasado mañana"
</code>
</pre>
170 changes: 88 additions & 82 deletions live-examples/js-examples/intl/meta.json
@@ -1,82 +1,88 @@
{
"pages": {
"intlCollatorPrototypeCompare": {
"exampleCode": "./live-examples/js-examples/intl/intl-collator-prototype-compare.html",
"fileName": "intl-collator-prototype-compare.html",
"title": "JavaScript Demo: Intl.Collator.prototype.compare",
"type": "js"
},
"intlCollatorPrototypeResolvedOptions": {
"exampleCode": "./live-examples/js-examples/intl/intl-collator-prototype-resolvedoptions.html",
"fileName": "intl-collator-prototype-resolvedoptions.html",
"title": "JavaScript Demo: Intl.Collator.prototype.resolvedOptions",
"type": "js"
},
"intlCollatorSupportedLocalesOf": {
"exampleCode": "./live-examples/js-examples/intl/intl-collator-supportedlocalesof.html",
"fileName": "intl-collator-prototype-supportedlocalesof.html",
"title": "JavaScript Demo: Intl.Collator.prototype.supportedLocalesOf",
"type": "js"
},
"intlCollator": {
"exampleCode": "./live-examples/js-examples/intl/intl-collator.html",
"fileName": "intl-collator.html",
"title": "JavaScript Demo: Intl.Collator",
"type": "js"
},
"intlDateTimeFormatPrototypeFormat": {
"exampleCode": "./live-examples/js-examples/intl/intl-datetimeformat-prototype-format.html",
"fileName": "intl-datetimeformat-prototype-format.html",
"title": "JavaScript Demo: Intl.DateTimeFormat.prototype.format",
"type": "js"
},
"intlDateTimeFormatPrototypeResolvedOptions": {
"exampleCode": "./live-examples/js-examples/intl/intl-datetimeformat-prototype-resolvedoptions.html",
"fileName": "intl-datetimeformat-prototype-resolvedoptions.html",
"title": "JavaScript Demo: Intl.DateTimeFormat.prototype.resolvedOptions",
"type": "js"
},
"intlDateTimeFormatSupportedLocalesOf": {
"exampleCode": "./live-examples/js-examples/intl/intl-datetimeformat-supportedlocalesof.html",
"fileName": "intl-datetimeformat-prototype-supportedlocalesof.html",
"title": "JavaScript Demo: Intl.DateTimeFormat.prototype.supportedLocalesOf",
"type": "js"
},
"intlDateTimeFormat": {
"exampleCode": "./live-examples/js-examples/intl/intl-datetimeformat.html",
"fileName": "intl-datetimeformat.html",
"title": "JavaScript Demo: Intl.DateTimeFormat",
"type": "js"
},
"intlGetCanonicalLocales": {
"exampleCode": "./live-examples/js-examples/intl/intl-getcanonicallocales.html",
"fileName": "intl-getcanonicallocales.html",
"title": "JavaScript Demo: Intl.GetCanonicalLocales",
"type": "js"
},
"intlNumberFormatPrototypeFormat": {
"exampleCode": "./live-examples/js-examples/intl/intl-numberformat-prototype-format.html",
"fileName": "intl-numberformat-prototype-format.html",
"title": "JavaScript Demo: Intl.NumberFormat.prototype.format",
"type": "js"
},
"intlNumberFormatPrototypeResolvedOptions": {
"exampleCode": "./live-examples/js-examples/intl/intl-numberformat-prototype-resolvedoptions.html",
"fileName": "intl-numberformat-prototype-resolvedoptions.html",
"title": "JavaScript Demo: Intl.NumberFormat.prototype.resolvedOptions",
"type": "js"
},
"intlNumberFormatSupportedLocalesOf": {
"exampleCode": "./live-examples/js-examples/intl/intl-numberformat-supportedlocalesof.html",
"fileName": "intl-numberformat-prototype-supportedlocalesof.html",
"title": "JavaScript Demo: Intl.NumberFormat.prototype.supportedLocalesOf",
"type": "js"
},
"intlNumberFormat": {
"exampleCode": "./live-examples/js-examples/intl/intl-numberformat.html",
"fileName": "intl-numberformat.html",
"title": "JavaScript Demo: Intl.NumberFormat",
"type": "js"
}
}
}
{
"pages": {
"intlCollatorPrototypeCompare": {
"exampleCode": "./live-examples/js-examples/intl/intl-collator-prototype-compare.html",
"fileName": "intl-collator-prototype-compare.html",
"title": "JavaScript Demo: Intl.Collator.prototype.compare",
"type": "js"
},
"intlCollatorPrototypeResolvedOptions": {
"exampleCode": "./live-examples/js-examples/intl/intl-collator-prototype-resolvedoptions.html",
"fileName": "intl-collator-prototype-resolvedoptions.html",
"title": "JavaScript Demo: Intl.Collator.prototype.resolvedOptions",
"type": "js"
},
"intlCollatorSupportedLocalesOf": {
"exampleCode": "./live-examples/js-examples/intl/intl-collator-supportedlocalesof.html",
"fileName": "intl-collator-prototype-supportedlocalesof.html",
"title": "JavaScript Demo: Intl.Collator.prototype.supportedLocalesOf",
"type": "js"
},
"intlCollator": {
"exampleCode": "./live-examples/js-examples/intl/intl-collator.html",
"fileName": "intl-collator.html",
"title": "JavaScript Demo: Intl.Collator",
"type": "js"
},
"intlDateTimeFormatPrototypeFormat": {
"exampleCode": "./live-examples/js-examples/intl/intl-datetimeformat-prototype-format.html",
"fileName": "intl-datetimeformat-prototype-format.html",
"title": "JavaScript Demo: Intl.DateTimeFormat.prototype.format",
"type": "js"
},
"intlDateTimeFormatPrototypeResolvedOptions": {
"exampleCode": "./live-examples/js-examples/intl/intl-datetimeformat-prototype-resolvedoptions.html",
"fileName": "intl-datetimeformat-prototype-resolvedoptions.html",
"title": "JavaScript Demo: Intl.DateTimeFormat.prototype.resolvedOptions",
"type": "js"
},
"intlDateTimeFormatSupportedLocalesOf": {
"exampleCode": "./live-examples/js-examples/intl/intl-datetimeformat-supportedlocalesof.html",
"fileName": "intl-datetimeformat-prototype-supportedlocalesof.html",
"title": "JavaScript Demo: Intl.DateTimeFormat.prototype.supportedLocalesOf",
"type": "js"
},
"intlDateTimeFormat": {
"exampleCode": "./live-examples/js-examples/intl/intl-datetimeformat.html",
"fileName": "intl-datetimeformat.html",
"title": "JavaScript Demo: Intl.DateTimeFormat",
"type": "js"
},
"intlGetCanonicalLocales": {
"exampleCode": "./live-examples/js-examples/intl/intl-getcanonicallocales.html",
"fileName": "intl-getcanonicallocales.html",
"title": "JavaScript Demo: Intl.GetCanonicalLocales",
"type": "js"
},
"intlNumberFormatPrototypeFormat": {
"exampleCode": "./live-examples/js-examples/intl/intl-numberformat-prototype-format.html",
"fileName": "intl-numberformat-prototype-format.html",
"title": "JavaScript Demo: Intl.NumberFormat.prototype.format",
"type": "js"
},
"intlNumberFormatPrototypeResolvedOptions": {
"exampleCode": "./live-examples/js-examples/intl/intl-numberformat-prototype-resolvedoptions.html",
"fileName": "intl-numberformat-prototype-resolvedoptions.html",
"title": "JavaScript Demo: Intl.NumberFormat.prototype.resolvedOptions",
"type": "js"
},
"intlNumberFormatSupportedLocalesOf": {
"exampleCode": "./live-examples/js-examples/intl/intl-numberformat-supportedlocalesof.html",
"fileName": "intl-numberformat-prototype-supportedlocalesof.html",
"title": "JavaScript Demo: Intl.NumberFormat.prototype.supportedLocalesOf",
"type": "js"
},
"intlNumberFormat": {
"exampleCode": "./live-examples/js-examples/intl/intl-numberformat.html",
"fileName": "intl-numberformat.html",
"title": "JavaScript Demo: Intl.NumberFormat",
"type": "js"
},
"intlRelativeTimeFormat": {
"exampleCode": "./live-examples/js-examples/intl/intl-relativetimeformat.html",
"fileName": "intl-relativetimeformat.html",
"title": "JavaScript Demo: Intl.RelativeTimeFormat",
"type": "js"
}
}
}

0 comments on commit 4648996

Please sign in to comment.