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

Allowing plugins (or any external code) to override existing formats #2165

Closed
seeschloss opened this issue Jan 16, 2015 · 2 comments
Closed

Comments

@seeschloss
Copy link

I am writing a library that handles French revolutionary calendar dates.

When looking into how I could use moment together with it, I found that it's quite difficult for a plugin to define new formats. The jalaali plugin has to completely wrap moment in order to add its jYYYY and so on formats. In the process, it also has to reimplement (often just copying) internal functions, just because it can't access and modify moment's internal variables.

I tried a quick modification of moment's code to allow plugins to declare "extraFormats" that will then be handled just like the default internal ones, here it is: seeschloss@ff4920f

That's not a pull request because:

  1. I'm not sure the moment project is interested at all in the idea
  2. It's far from complete, doesn't provide any support for parsing these extra formats
  3. Kind of a quick hack (especially the really ugly RegExp modification part) and could be done in other, probably better, ways

Basically, before doing anything better I'd like to know what you think of this idea? Is it worth it?

@ichernev
Copy link
Contributor

Adding formats, tokens etc is part of adding pluggable calendar systems: #1454

PRs welcome.

@marwahaha
Copy link
Member

Closing due to age. Still, a cool idea, please open a PR if you're interested.

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

3 participants