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

add diff(), add(), subtract() functions support #77

Closed

Conversation

tryhubov
Copy link
Contributor

hi

Context

Notice

  • i've extended example app to include new functions
  • i've added py3.9 support for tox/ci
  • i've rewritten javascript to enable format add() and subtract() results
    • we can't use moment js chaining like moment().add(1, 'days').format('L') because of one-way communication between python and js code. so we must pass format as parameter to functions that return raw datetime to pretty print result in templates
  • i've refactored how js functions parameters are construct to reuse data keys (in html attributes data-)
  • i've refactored tests to reference those data keys

p.s. ping me if something requires enhancement

@tryhubov tryhubov changed the title Feat/manipulate-funcs add diff(), add(), subtract() functions support May 31, 2021
@miguelgrinberg
Copy link
Owner

miguelgrinberg commented May 31, 2021

Thanks. First of all, I have to say that I don't really see what is the use case for these functions, because neither of the three are about rendering timestamps. These perform operations with timestamps, which I would expect the application will either do in Python or in JavaScript. Doing these in a template isn't really a great solution, because you can't really use the result, the only thing you can do with it is print it.

Second, you've essentially rewrote most of the library to make supporting these three functions possible, so it'll take me some time to review and make sure that you haven't indirectly changed any behavior of the current version.

Third, the format argument that you added to account for the fact that there is no way to chain calls is weird. A design goal of this library is to try to stay as close as possible to the moment API. This would be a major departure from that, and also in an inconsistent way, because the only operation that can be done on results of adding, subtracting and diffing is to call format, ie there is no way to use any of the other formatting options.

@tryhubov
Copy link
Contributor Author

tryhubov commented May 31, 2021

Thanks for the review. OK, i've understood your points. You are absolutely right about add and subtract, i just wanted to add diff() for my little project but found an issue that asks for all three functions and wanted to help :)
But don't you think that diff() concerns rendering? it's in the "display" section in moment js docs

@tryhubov tryhubov closed this May 31, 2021
@tryhubov tryhubov deleted the feat/manipulate-funcs branch May 31, 2021 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants