Skip to content

Add more date patterns #201

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

Merged
merged 6 commits into from
Jan 11, 2023
Merged

Add more date patterns #201

merged 6 commits into from
Jan 11, 2023

Conversation

BelKed
Copy link
Contributor

@BelKed BelKed commented Jan 9, 2023

It seems that the date format no longer depends on the language settings. In Settings > Preferences, you can find a Date Format section, where you can set a variety of date formats:

Screenshot


This PR adds support for all of them.
Related to stale #155.

@FriedrichFroebel
Copy link
Collaborator

Thanks for the updated PR. Is there any reason for dropping the г format completely, whereas only Windows is affected (maybe related to https://bugs.python.org/issue8304)? We already have exceptions for Windows date formats inside our code and should probably use a similar approach here:

eat_zero_prefix = "#" if platform.system() == "Windows" else "-"

Just for the record, the offending exceptions is the following one:

>           formatted_date = datetime.datetime.strftime(date, pattern)
E           UnicodeEncodeError: 'locale' codec can't encode character '\u0433' in position 9: encoding error

@BelKed
Copy link
Contributor Author

BelKed commented Jan 10, 2023

Just the Windows build was failing…
I’ll take a look at it in the evening and hopefully add a commit with fix for Windows :)

@FriedrichFroebel FriedrichFroebel changed the title Add more date patters Add more date patterns Jan 10, 2023
@BelKed
Copy link
Contributor Author

BelKed commented Jan 10, 2023

As I promised, I fixed it...

Feel free to let me know about any issues with this solution :)

@FriedrichFroebel
Copy link
Collaborator

Thanks, seems legit to me. Nevertheless, I would probably prefer to avoid this overhead for Linux and macOS. Could you make the offending section conditional, please? Meaning:

if platform.system() == "Windows":
    # Use solution with encoding and decoding.
else:
   # Use old solution.

@BelKed
Copy link
Contributor Author

BelKed commented Jan 10, 2023

Sure, 8e2acd2

Copy link
Collaborator

@FriedrichFroebel FriedrichFroebel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your fix and patience.

@FriedrichFroebel FriedrichFroebel merged commit 5ee052f into tomasbedrich:master Jan 11, 2023
@BelKed BelKed deleted the add-date-patters branch January 11, 2023 11:09
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