Skip to content

Commit 36698c0

Browse files
authored
Merge pull request #550 from keymanapp/fix/545-day-buckets
fix: break contributions down into days by current timezone
2 parents b85349c + 9772fbc commit 36698c0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

public/src/app/data/data.model.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,17 @@ export class DataModel {
278278
this.phase = {title:'?'};
279279
} else {
280280
// Assuming a phase is 2 weeks; we can't really show more than that on screen easily anyway!
281-
this.phaseEnd = new Date(this.phase.end).toDateString();
282-
this.phaseStart = new Date(this.phase.start).toDateString();
283281

284-
let d = new Date(this.phase.start);
282+
// use current timezone; we are assuming phase.end and phase.start end
283+
// with 'Z', so we trim that off and automatically get midnight on the
284+
// date in question. This does mean that each site user will see their
285+
// contributions broken down by their current viewing timezone -- so the
286+
// contributions table will differ from user to user.
287+
this.phaseEnd = new Date(this.phase.end.substring(0,this.phase.end.length-1)).toDateString();
288+
this.phaseStart = new Date(this.phase.start.substring(0,this.phase.start.length-1)).toDateString();
289+
290+
let d = new Date(this.phase.start.substring(0,this.phase.start.length-1));
285291
d.setUTCDate(d.getUTCDate()-2); // Unofficial start date is the Sat before the start of sprint (which is a Monday)
286-
// TODO: sort out timezones one day ...
287292

288293
let dayName = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
289294
let monthName = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -292,10 +297,10 @@ export class DataModel {
292297
let dt = new Date(d.valueOf()+n*86400*1000);
293298
this.sprintDays[n] = {
294299
date: dt,
295-
dayText: dayName[dt.getUTCDay()],
296-
monthText: monthName[dt.getUTCMonth()],
297-
dateText: dt.getUTCDate().toString(),
298-
ghdate: dt.toISOString().substr(0,10)
300+
dayText: dayName[dt.getDay()],
301+
monthText: monthName[dt.getMonth()],
302+
dateText: dt.getDate().toString(),
303+
ghdate: dt.toISOString().substring(0,10)
299304
};
300305
}
301306
}

0 commit comments

Comments
 (0)