Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use conventional syntax for formatting #49

Closed
defunctzombie opened this issue Nov 10, 2011 · 5 comments
Closed

use conventional syntax for formatting #49

defunctzombie opened this issue Nov 10, 2011 · 5 comments

Comments

@defunctzombie
Copy link

I don't know why you invented your own format specifiers, but things like stftime (and that family of methods) have a well known set of format specifiers. Would be nice if you could just use those instead of making new ones which won't match up to what someone may already be using.

@timrwood
Copy link
Member

There are too many different date format tokens syntaxes for me to match any standard.

See this comment. #36 (comment)

That explains my rationale for why I chose the tokens I did.

@defunctzombie
Copy link
Author

I would think using the strftime notation would be quite reasonable as it would be found on all platforms in some form. The fact that things like unix, python, php, ruby, c/c++, etc all support it should tell you something :)

When looking for a simple date library to use over the builtin one, I would pick something that mimics strftime or just not bother personally.

@timrwood
Copy link
Member

The intention of this library is not to port strftime. It is to provide a safe and robust collection of common functionality regarding dates.

There are many implementations of strftime in javascript. A brief search on github found the following:

https://github.com/drench/strftime.js
https://github.com/loopj/commonjs-date-formatting
https://github.com/zaius/jdate
https://github.com/samsonjs/strftime
https://github.com/gf3/JS-strftime

I'm not too experienced with formatting dates in unix, python, ruby, or c++, but I know php has both strftime and date for formatting dates, and the tokens for those functions vary wildly.

http://php.net/manual/en/function.strftime.php
http://php.net/manual/en/function.date.php

As described in the comment I linked to above, the reason I chose the tokens I did was to aid readability. I believe the tokens I chose would be much easier to remember or deduce than strftime tokens for someone who hasn't been exposed to either.

I don't mean to start an argument, hopefully you can understand my rationale for designing the library this way.

@AndrewIngram
Copy link

To revive a very old topic. I'm going to end up using the moment-strftime/moment-tokens library, simply because I need interoperability with Django's internationalisation code. Here's an example of some (admittedly horrible) JavaScript generated by the framework to aid in client-side internationalisation: https://www.onefinestay.com/jsi18n/

As you can see, it exposes the strftime syntax for date/time/datetime formatting, which the client-side code can use at will.

Not trying to reverse your decision, since your reasoning makes sense to me, but just providing a use case.

butterflyhug pushed a commit to WhoopInc/frozen-moment-OLD that referenced this issue Jul 22, 2014
@henrik
Copy link

henrik commented Aug 27, 2015

moment-strftime link for reference: https://github.com/benjaminoakes/moment-strftime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants