GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Embed Notice

HTML Code

Corresponding Notice

  1. Embed this notice
    Mark Gritter (markgritter@mathstodon.xyz)'s status on Friday, 17-Jan-2025 15:01:30 JSTMark GritterMark Gritter

    Go's zero time is year 1, not 1970 or something Unix-y like that. That's fine.
    Except:

    func main() {
    origin := time.Time{}
    t := time.Date(2025, 1, 16, 4, 0, 0, 0, time.UTC)
    d := t.Sub(origin)
    t2 := origin.Add(d)
    fmt.Println(t2)
    }

    results in 0293-04-11 23:47:16.854775807 +0000 UTC

    https://go.dev/play/p/turgQXfyJG-

    There's obviously an integer overflow happening here and it's too late in the day for me to figure out how to work around it.

    What I need to do is truncate times to a 64-hour or 256-hour boundary. Our existing Go code truncates relative to Go's zero time. TimescaleDB truncates relative to 2001-01-01, or 2001-01-03 in some cases when calculating buckets. It seems challenging to write code that handles both, if the invariant t.Sub(origin).Add(origin) == t does not hold.

    #golang

    In conversationabout 5 months ago from mathstodon.xyzpermalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.