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

Quick Sets #72

Open
wino45 opened this issue Jan 8, 2021 · 2 comments
Open

Quick Sets #72

wino45 opened this issue Jan 8, 2021 · 2 comments

Comments

@wino45
Copy link

wino45 commented Jan 8, 2021

Some of the Quick Sets are not working today (Jan 8): 14 days, 30 days,..
All of them that go back to year 2020.

@aardappel
Copy link
Owner

Yup.. looks like it doesn't manage to cross the year boundary..

@aardappel
Copy link
Owner

Ok, this is going to be somewhat hard to fix:

const int monthfactor = 32;
const int yearfactor = 512;
const int yearbase = 2000;
int dayordering(SYSTEMTIME &st) {
return st.wDay + st.wMonth * monthfactor + (st.wYear - yearbase) * yearfactor;
}

Internally, a "day" is number derived from the date, but it doesn't count 365 days in the year, it does 512, such that the day has a fixed number of bits in the date representation.

So the problem with the "14 days quick set" on Jan 8 is that it reaches into 6 unused days in the previous year.

This is frankly a bad design, but is hard to fix now, because these day numbers are stored in the database.

So there's two solutions:

  1. Bump to a new version in the database format, where these day numbers are contiguous. Convert from the old representation on load.
  2. Leave this format as is, but write a function for "quick set" that knows how many days to go into the past for to account for the blank days in between months and years.

2 is a lot simpler, 1 is cleaner..

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