Last active
April 23, 2019 18:23
-
-
Save shisama/d50271634a4e76c7d8909109411170f2 to your computer and use it in GitHub Desktop.
Intl.RelativeTimeFormat - New JavaScript Features in Node.js v12
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
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('ja', { numeric: 'auto' }); | |
console.log(rtf2.format(2, 'day')); | |
//expected output: "明後日" | |
var rtf3 = new Intl.RelativeTimeFormat('en', { style: 'narrow', numeric: 'auto' }); | |
console.log(rtf3.format(1, 'day')); | |
//expected output: "tommorow" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment