Getting the days of the week the hard way, because there is no better way I try this:
var Jan1 = Gregorian.moment({:year => 2023, :month => 1, :day => 1}); for (var i = 0; i < self.DoW.size(); i++) { var DDD = Gregorian.info(Jan1.add(new Time.Duration(86400*i)), Time.FORMAT_MEDIUM); self.DoW[i] = DDD.day_of_week.substring(0,2).toUpper(); }
But DoW[0] = "SA"? My calendar says something different, so I try this:
var Jan1 = Gregorian.moment({:year => 2023, :month => 1, :day => 1, :hour => 12}); for (var i = 0; i < self.DoW.size(); i++) { var DDD = Gregorian.info(Jan1.add(new Time.Duration(86400*i)), Time.FORMAT_MEDIUM); self.DoW[i] = DDD.day_of_week.substring(0,2).toUpper(); }
Just by adding hour = 12 now I get the correct answer, DoW[0] = 'SU'. I'm pretty sure the day of the week is the same for all hours on Jan 1. Is this some time zone bug?