Comments (4)
in case it helps this is what I came up with (in python) that seems to do the job:
def gregorianToHT(_date, useLocal = False, iLeagueID=None):
ORIGIN = date(1997, 6, 2)
dayDiff = (_date-ORIGIN).days
season = dayDiff // 112
week = (dayDiff % 112 // 7) + 1
if useLocal:
assert iLeagueID is not None, "if useLocal = True, iLeagueID should be provided"
season += dSeasonOffset[iLeagueID]
return season, week
# some tests ======
assert gregorianToHT(date(2020, 6, 27)) == (75, 4)
assert gregorianToHT(date(2018, 5, 10)) == (68, 5)
assert gregorianToHT(date(2009, 5, 28)) == (39, 2)
assert gregorianToHT(date(2020, 8, 31), True, 52) == (60, 14)
from foxtrick.
>>> str(date(2020, 8, 31))
'2020-08-31'
new Date(2020,8,31).toString()
"Thu Oct 01 2020 00:00:00 GMT+0200 (Central European Summer Time)"
Does that answer your question?
from foxtrick.
To be specific, this passes no problem:
gregorianToHT = (...args) => { let {season, week} = Foxtrick.util.time.gregorianToHT(...args); return season*16 + week; };
console.assert(gregorianToHT(new Date(2020, 5, 27)) == 75*16+4);
console.assert(gregorianToHT(new Date(2018, 4, 10)) == 68*16+5);
console.assert(gregorianToHT(new Date(2009, 4, 28)) == 39*16+2);
from foxtrick.
For JS weirdness see MDN docs. I.e. month starts from 0. I know, I know.
Keep in mind, that local season is specific to the running user, and we also (sometimes) take into account HTDateFormat settings.
The sometimes part should probably be fixed. But I don't think this issue itself is valid
from foxtrick.
Related Issues (20)
- Changes to Dashboard - MyOffice breaks multipal modules HOT 1
- Web page has been down a few days HOT 1
- redir_to_coach is broken after coach reform HOT 2
- [player-stats-experience] Table is slightly broken for players with no best performance (that is, new players in a team)
- LiveAlert not working.
- Transfer search "born in" box is hidden HOT 1
- MyMonitor: doesn't support showing NT/U21 last/next match HOT 2
- Wrong formula in HTMS Potential HOT 1
- No rating colors in match commentary in new interface HOT 4
- ConfirmActions for putting a player on transferList needs a check-up HOT 1
- Youth current skill and potential is reversed on CopyPlayerAd HOT 2
- [player-stats-experience] XP computation is broken since new Hattrick icons HOT 3
- Commits are not getting released to FF! HOT 4
- Display of extra-wide tables in Hattrick Posts
- Module ShowLineupSet doesn't work properly anymore HOT 1
- Experience and Loyalty factors not working in Firefox
- foxtrick.org is non-responsive HOT 1
- New leagues and divisions
- ongoingEvents Tab not properly visible HOT 4
- Live games header position issue HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from foxtrick.