#1262 util.datetime has a small chance to be off by one second

Reporter Zash
Owner Zash
Created
Updated
Stars ★ (1)
Tags
  • Status-Fixed
  • Milestone-0.11
  • Difficulty-Easy
  • Priority-Medium
  • Type-Defect
  1. Zash on

    https://buildbot.prosody.im/#/builders/1/builds/274/steps/4/logs/stdio Failure -> https://hg.prosody.im/trunk/file/2db341f7c5fc/spec/util_datetime_spec.lua#l69 util.datetime #parse should work spec/util_datetime_spec.lua:69: Expected objects to be equal. Passed in: (number) 1136239445 Expected: (number) 1136239444 Most likely cause is that the two os.date() calls in the timezone calculation happen close enough to when a second rolls that one ends up on the next https://hg.prosody.im/trunk/file/2db341f7c5fc/util/datetime.lua#l41 Collecting the current time and passing it to both os.date() calls should solve it.

  2. Zash on

    Fixed in https://hg.prosody.im/trunk/rev/e616c37756b3

    Changes
    • owner Zash
    • tags Status-Fixed Milestone-0.11

New comment

Not published. Used for spam prevention and optional update notifications.