matttrenary / rugby-ratings

Calculate ratings from rugby scores
2 stars 1 forks source link

Date Calc Different Depending on OS #30

Closed grjanke closed 2 weeks ago

grjanke commented 4 weeks ago

Windows and Mac require a different wildcard in the date string to make the date show up correctly on the website. Solve this!

grjanke commented 3 weeks ago

I just opened a new branch (resolve-os-diffs) and pushed three commits.

What was the issue? In python's datetime library, the strftime() func originates from C, and the C is compiled with a different version depending on a computer's operating system. The date formats (which begin with %) are different for each OS.

How did I fix the issue? Before our implementation of strftime() in site_builder.py and calc_ratings.py, I added an if-then statement that checks which operating system the user is using (see lines 46 and 318, respectively). After that, it uses the operating-system-specific function call.

grjanke commented 3 weeks ago

@matttrenary Please test my changes on your Windows system, using the commands below.

git pull
git checkout resolve-os-diffs
python calc_ratings.py
python site_builder.py
python -m http.server

Then, navigate to (probably?) localhost:8000 and scroll through the site and make sure all of the dates look normal.

If we're all good, then I can merge the branches! Otherwise, I must have messed up the date formats on Windows.

matttrenary commented 3 weeks ago

It worked!

Not sure if related, but the datestamp at the bottom of a page is a little funky: image

matttrenary commented 3 weeks ago

Updated code and committed. Can you test?

The "#" character works on Windows like the "-" character on Mac in date formatting. I was also getting full time zone names instead of acronyms so I decided to use a couple more packages in order to use %Z in the date format for the time zone. I'd expect that you could do the same and simplify the Mac code, removing the if/else for daylight savings.

matttrenary commented 3 weeks ago

Updated copyright symbol with the html code for the symbol within base_template.html. Can you test that works on Mac, George?

grjanke commented 2 weeks ago

Oops. Didn't get around to updating the Mac code if/else for daylight savings, but that's beyond the scope of this issue, since the goal was just to get it working on all OSes. Can fix later as part of code cleanup.

Copyright symbol and everything else works. Merged the branch. Closing this issue!