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

Without opting-in into extended mode Date.create returns an ordinary non-extended date #605

Open
faridnsh opened this issue Jul 31, 2017 · 3 comments
Milestone

Comments

@faridnsh
Copy link
Contributor

The title says it all. Here's an example on how to reproduce it:

require('sugar').Date.create().format()

For now as a work around I'm wrapping create calls with Date:

const { Date } = require('sugar');
const myDate = Date(Date.create(...));
@andrewplummer
Copy link
Owner

This is expected behavior. The idea is that all methods on the Sugar.Date object are static methods that always return native objects, while it is required to either extend or use chainables with new Sugar.Date() for objects with extended functionality.

I realize that the signature Sugar.Date.create lends to the thinking that it would return a Sugar date as opposed to a normal one, and I also find it a bit annoying that it feels somewhat misleading. One idea I've had is to change the naming of create to parse.. Note also that this method is automatically when creating chainables so that you can do something like new Sugar.Date('tomorrow') instead of needing to do new Sugar.Date(Sugar.Date.create('tomorrow')).

I'm open to other suggestions here to help make this more intuitive if you have them.

@faridnsh
Copy link
Contributor Author

I think this is just a documentation issue, it makes sense. Not sure what can be added to the docs though. Feel free to close this. :)

@andrewplummer andrewplummer added this to the Next Major milestone Aug 6, 2018
@andrewplummer
Copy link
Owner

Going to revisit naming here for the next major verison... maybe there's a way to make this one more intuitive.

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

2 participants