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

adding support for expressions of the for {x+/-y} to allow for offsets #1189

Merged
merged 1 commit into from
May 21, 2023

Conversation

dbcSolid
Copy link

I use ElevenClock in my organization to display the current work week (%W) using the custom formatting options (it's very useful thanks!). Unfortunately my organization uses a different definition of work week so some years there is an off by one error. It looks like ElevenClock uses the strftime C function which defines week 1 as starting on the first Monday. There is an ISO standard (ISO 8601) that defines things differently (Week 1 is the first week with a majority of its days in Jan), and my org uses a third definition.

My recommendation is to allow offsets/expressions in the custom data formatting to solve this problem more generally. e.g

%a {%W+1}.%w to add 1 week

I imagine it could be useful for other offsets I'm not thinking of.

I'm open to other solutions, but I have already implemented a fix for myself using a simple evaluation function that supports basic addition and subtraction inside {}'s as above that wraps the calls to strftime.

If there is interest I would be happy to create a pull request so others could benefit. It's a relatively small change, but I personally know a bunch of folks that would find it very useful.

@dbcSolid
Copy link
Author

I added this expression parser to the settings panel so you can see the preview as well as where I think it is needed in init.py so it shows up correctly in the taskbar (if I missed any other places it is needed, should be easy to add). Currently it only supports addition and subtraction for simple offsets (I can't fathom a need to multiply a date) but should be easily expandable to more complex expressions if desired

@marticliment marticliment merged commit 01ad284 into marticliment:main May 21, 2023
@marticliment
Copy link
Owner

I will release a beta soon

@marticliment
Copy link
Owner

Hello,

a beta release has been published containing your changes:
https://github.com/marticliment/ElevenClock/releases/tag/4.2.0-beta

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

Successfully merging this pull request may close these issues.

2 participants