It seems indeed to be better. I replaced the getWeek function with your update. After a reload of the page and using your test code I get the correct week 45 even after 23:00
It also switch to week 46 if I enter a date for next week ;) As you say more test is required to be sure that it doesn't break something else. That's what I call reactivity!! Philippe On Sunday, 13 November 2016 14:42:50 UTC, PMario wrote: > > On Sunday, November 13, 2016 at 10:49:48 AM UTC+1, Jeremy Ruston wrote: >> >> I think the reason it happens at 23h00 local time might be because that's >> when the corresponding UTC time flips into the next day. >> > > I think I found the problem. Some more tests needed. > > imo it's: > https://github.com/Jermolene/TiddlyWiki5/blob/master/core/modules/utils/utils.js#L361 > > that causes the problem > especially: new Date(dt.getFullYear(),0,1) + 3600000 creates nonsense if > you try it in the console. > > IMO getWeek needs too look like this: > > exports.getWeek = function(date) { > var dt = new Date(date.getTime()); > var d = dt.getDay(); > if(d === 0) { > d = 7; // JavaScript Sun=0, ISO Sun=7 > } > dt.setTime(dt.getTime() + (4 - d) * 86400000);// shift day to Thurs of > same week to calculate weekNo > var x = new Date(dt.getFullYear(),0,1); > var n = Math.floor((dt.getTime() - x.getTime()) / 86400000); > return Math.floor(n / 7) + 1; > }; > > ------------------ > > Some more TW code to play with Week display, without waiting till 23:00 > your time :) > > <$view field="created" format=date template="YYYY-MM-DD 0hh:0mm:0ss. -- > kw: WW -- Z TZD"/><br> > > <$view field="time" format=date template="YYYY-MM-DD 0hh:0mm:0ss. -- kw: > WW -- Z TZD"/> > > Add a field named: time to your tiddler eg: time: 20161112225959 > > have fun! > mario > PS: I'll create a PR after testing the fix. > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/1185c890-8e27-4928-ad8a-29edb097a68d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

