Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upWhat about proper String, Date and Number formatting? #939
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
IgnoredAmbience
Jun 22, 2017
Member
Template literals partially cover your second request. https://hacks.mozilla.org/2015/05/es6-in-depth-template-strings-2/
I believe an updated Date API is in progress, here: https://github.com/maggiepint/proposal-temporal
|
Template literals partially cover your second request. https://hacks.mozilla.org/2015/05/es6-in-depth-template-strings-2/ |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
devlato
Jun 22, 2017
@IgnoredAmbience yes, but I guess I cannot use a template string as a template? I mean, is it possible to store the template in a variable and interpolate on demand? I.e.:
// I'm using usual quotes there because otherwise the string will be interpolated immediately
const template = 'Hello, Mr ${lastName}';
// ...
// And somewhere there we use template variable from above to format the result.
I'm asking because all the languages typically have this feature and because this approach is serializable. Typical use case – to read the template string from localization file or from any another source and use as a template.
devlato
commented
Jun 22, 2017
•
|
@IgnoredAmbience yes, but I guess I cannot use a template string as a template? I mean, is it possible to store the template in a variable and interpolate on demand? I.e.:
I'm asking because all the languages typically have this feature and because this approach is serializable. Typical use case – to read the template string from localization file or from any another source and use as a template. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
domenic
closed this
Jun 22, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
littledan
Jun 23, 2017
Member
ECMA 402 is a good place to discuss this further as well; see tc39/ecma402#21 . Generally, for now, you can use moment.js for this sort of thing.
|
ECMA 402 is a good place to discuss this further as well; see tc39/ecma402#21 . Generally, for now, you can use moment.js for this sort of thing. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jungshik
Jun 24, 2017
Contributor
Ecma 402 certainly is. There's a better bug for this than tc39/ecma402#21. I can't find it now, but will add a reference to that later.
|
Ecma 402 certainly is. There's a better bug for this than tc39/ecma402#21. I can't find it now, but will add a reference to that later. |
devlato commentedJun 22, 2017
•
edited
Hello guys and ladies,
what do you think about adding some common String and Date formatting APIs finally? Currently if you need to format a date, you have to use third party library or write tons of code, and formatting of dates is required in almost any project. Why don't add some APIs similar to moment.js API to the standard library?
I.e.
Or for strings:
Or for numbers:
I mean, it's 2017, and there is still no formatting API in standard library