Hello,
I want to get Time.moment value for today's midnight. I wrote following function:
function getTodayMidnightMoment()
{
var nowMoment = new Time.Moment(Time.today().value());
var nowGregorianInfo = Gregorian.info(NowMoment, Time.FORMAT_MEDIUM);
var todayMidnight = {
:year => NowGregorianInfo.year,
:month => NowGregorianInfo.month,
:day => NowGregorianInfo.day,
:hour => 0,
:minute => 0,
:second => 0
};
var midnightMoment = Gregorian.moment(todayMidnight);
return midnightMoment;
}
So it basically checks current date, and tries to get Gregorian.moment for this date, with hour, minute, and second set to 0.
It works, but it returns moment one hour later - 01:00:00 of current day. I'm not sure what causes this, maybe it's related to daylight saving being enabled? If this is the case, is it somehow possible to programmatically check if watch has daylight saving enabled? Or is there any other method to get actual moment.value for midnight of current time zone?
Thanks,
Wojtek