I think Time.toady() should return a different result

Former Member
Former Member
Time.today() is documented as "Use today() to get a Moment for the beginning of today based on your current GPS location."


I do not believe it behaves in this manner. Were it based on your GPS location, it would roll over when you see a new day, however it rolls over when UTC sees a new day, so is out of sync with current GPS location.


I think this function should roll over when (UTC + TZO) % 86400 == 0.
  • Former Member
    Former Member over 10 years ago
    To elaborate... My TZ is currently + 11. Here is my function to fix the problem.
    function timeToday() {
    var timeNow = Time.now().value() + System.getClockTime().timeZoneOffset;
    var today = timeNow % 86400;
    return timeNow - today;
    }


    At 10:30
    GARMIN Time.today().value() = 1427328000
    SHARKY timeToday() = 1427414400

    At 11:30
    GARMIN Time.today().value() = 1427414400
    SHARKY timeToday() = 1427414400
  • Former Member
    Former Member over 10 years ago
    Most days have 86400 seconds, but not all.

    So you will need to calculate how many seconds are in todays day in order for this to work all of the time.
  • Are we worrying about leap seconds, or something else?
  • Former Member
    Former Member over 10 years ago
    Most days have 86400 seconds, but not all.

    So you will need to calculate how many seconds are in todays day in order for this to work all of the time.
    Perhaps. But every 24 hour period has 86400 seconds.