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

maya.when() accepts string containing epoch, but computes wrong time #107

Closed
LuccoJ opened this issue Nov 18, 2017 · 3 comments
Closed

maya.when() accepts string containing epoch, but computes wrong time #107

LuccoJ opened this issue Nov 18, 2017 · 3 comments

Comments

@LuccoJ
Copy link

LuccoJ commented Nov 18, 2017

In [14]: epoch=str(maya.now().epoch)

In [15]: str(maya.MayaDT(epoch))
Out[15]: 'Fri, 17 Nov 2017 23:59:38 GMT'

In [16]: str(maya.when(epoch))
Out[16]: 'Sat, 18 Nov 2017 00:59:38 GMT'

I guess it should either return the same value as the constructor does, instead of apparently the value shifted by an hour (which might be timezone-dependent), or simply refuse to process this type of input (which is what maya.parse() does):

In [17]: str(maya.parse(epoch))
[...]
ParserError: Invalid date string: 1510963178

@kennethreitz
Copy link
Owner

when is for human dates, parse is for machine dates.

@kennethreitz
Copy link
Owner

we have a seperate method for from_epoch

@LuccoJ
Copy link
Author

LuccoJ commented Nov 22, 2017

I still think that in that case it should refuse to process the non-human date, instead of silently processing it wrong by a subtle amount of time... also considering that almost by definition, when you're processing dates input by a human, you cannot know what exactly to expect, so if the human somehow decides to input an epoch instead of a standard human date, that should probably result in an exception, not a silent failure.

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