I think it leads to side effects because it uses clib's time functions. I have 
a pure nim implementation of times, calendars and timezones here: 
[https://github.com/treeform/chrono](https://github.com/treeform/chrono)
    
    
    import chrono
    
    proc test1(unixTime: int64): bool =
      var
        t = Timestamp(unixTime) # in seconds?
        c = t.calendar
      c.toStartOf(Day)
      echo c.ts
      echo c.formatIso
    
    func test(unixTime: int64): bool =
      var c = Timestamp(unixTime).calendar # convert to calendar
      c.toStartOf(Day) # rewind calendar to start of day
      c.ts.float == 0 # convert calendar to timestmap, then to float
    
    discard test1(1233456789)
    discard test(1233456789)
    
    
    Run

But honestly it might be easier to just quantize your thing by a day if you 
don't care about timezones and daylight savings.
    
    
    unixTime - unixTime mod (24*60*60)
    
    
    Run

Reply via email to