I think the main reason to have a FormatComponent is to give each DateTimeFormat instance a configuration state so that once you define it you can "format" it automatically any time you print it out.
Said that, I am familiar as example with gmdate() PHP function or similar "string syntax" as it could be "%.2f" for numbers and I agree these are more handy and more "JavaScripysh" so that if ES.next won't have them, many developers will try to add these shortcuts into Data.prototype object with {writable:false,enumerable:false,configurable:false} descriptor. This underlines one more time too much abstraction or engineering may result into less practical usage for daily basis tasks. +1 for Nicholas idea On Fri, Oct 28, 2011 at 9:35 PM, Nicholas Zakas <standa...@nczconsulting.com > wrote: > I've just been reviewing the internationalization spec: > > https://docs.google.com/document/pub?id=1rsUxJQ03Ql6o3bh6RN7J81dtYZXE7OVsdQBw_h5ASnM&ndplr=1&pli=1 > > First off - hooray! This is long, long, long overdue. > > The biggest question I have is with regards to the DateTimeFormat and > NumberFormat. I'm wondering why you've chosen to have these as separate > object types instead of adding methods onto Date.prototype and > Number.prototype, respectively? It doesn't seem like having these as > separate objects provides much more value since they mostly just use their > format() methods. > > Smaller question is on specifying the format. The object literal > specification of the format seems overly verbose for dates, and perhaps > also for numbers. I'd really love to be able to do something like this: > > var now = Date(); > console.log(now.format("hh:mm:ss")); > > var price = 1010; > console.log(price.format("#,###")); > > I'd hypothesize that most programmers are familiar with this type of > date/numeric formatting strings as they are in use in other languages. I'd > much prefer being able to use a formatting string vs. an object literal > with multiple properties that aren't very transparent as to their > consequence. > > Just to emphasize: I really like the functionality in the spec, it just > seems more Java-like and verbose than what's in JavaScript right now, and > I'm wondering if there are ways to change that. > > Thanks, > Nicholas > > > ________________________________________ > Nicholas C. Zakas > http://www.nczonline.net > @slicknet > > > > > > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss