Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Intl.RelativeDateFormat example (#1245)
* Adding RelativeDateFormat example * Updated code example * fix wrong value
- Loading branch information
1 parent
24100f6
commit 4648996
Showing
2 changed files
with
103 additions
and
82 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
live-examples/js-examples/intl/intl-relativetimeformat.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} |