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

New Feature: parse and reformat date in view #29

Open
bordaigorl opened this issue Nov 23, 2015 · 4 comments
Open

New Feature: parse and reformat date in view #29

bordaigorl opened this issue Nov 23, 2015 · 4 comments
Milestone

Comments

@bordaigorl
Copy link

It would be nice to have a command to parse the selection in a view assuming it's a date, then present the user with a panel with the output formats to which the date can be transformed.

@FichteFoll
Copy link
Owner

That's a good idea. I will couple that with #15 when I work on it.

How would you suggest to determine the format of the timestamp parsed?

@FichteFoll
Copy link
Owner

Yeah, I could just use the same panel as in InsertDatePanelCommand. I could also attempt to parse the string(s) with all format strings from the prompt_config setting (minus tz_in and tz_out variants) and take whatever matches - and only ask for an explicit format if none matches.

If the above works like I think it could, i'll most likely implement it like that.

@bordaigorl
Copy link
Author

If I were to do it, I would try to see if the dateutil module works with ST's python (it is not bundled with ST3 as far as I can see).
It contains a parse function that tries to guess the format (see here).
As an ugly fallback, if nothing else works, you could try parsing the date using each template with datetime.strptime.

Also, I would probably not write new command but exploit the current ones adding a, say, date optional argument (default to None): when None do as now (backward compat), when now or tomorrow or few other keywords compute the corresponding date, when selection or a generic string try to parse.

@FichteFoll
Copy link
Owner

Thanks for the hint. dateutil looks like it could easily be made compatible with ST and I can just bundle it as a dependency, like I did with pytz.

I think that would be enough info to start working on this.
Don't expect it too soon though, I have many things with higher priority currently, so for the moment you'll either have to stick to regular expressions or implement it on your on and file a pull request.

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

No branches or pull requests

2 participants