Skip to content

Conversation

@shamaton
Copy link
Owner

Summary (Breaking Change)

This PR changes the default Location used when decoding MessagePack Timestamp into Go’s time.Time from Local to UTC. The encoded/decoded instant is unchanged (MessagePack Timestamp stores seconds+nanos only); only time.Time.Location() differs.
Closes #51.


Motivation & Background

  • MessagePack Timestamp represents an instant and does not carry timezone info.
  • Decoding to Local by default leads to environment-dependent results (different hosts show different zones) and surprises in distributed systems/APIs.
  • Defaulting to UTC provides a predictable, portable baseline.

What’s in this PR

  • Default behavior (v3): Decoded time.Time is now UTC by default.

  • Global switches (new):

    • msgpack.SetDecodedTimeAsUTC() – force decoded time.Time to use UTC (v3 default).
    • msgpack.SetDecodedTimeAsLocal() – force decoded time.Time to use Local (restores v2-like behavior).
  • Docs:

    • Add a README Announcement near the top to highlight the change.

Public API (surface)

// Global configuration (process-wide). Call during init/main.
msgpack.SetDecodedTimeAsUTC()   // v3 default
// or
msgpack.SetDecodedTimeAsLocal() // restore v2-like behavior
  • No change to the on-wire format or marshal behavior.
  • The new functions are additive; the default change to UTC is the only breaking aspect.

Migration Guide (short)

  • If you need the old behavior (Local):

    msgpack.SetDecodedTimeAsLocal()
  • Recommended for distributed systems/APIs: keep or explicitly set the new UTC default:

    // Optional, v3 already defaults to UTC
    msgpack.SetDecodedTimeAsUTC()

@shamaton shamaton self-assigned this Oct 13, 2025
@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.18%. Comparing base (9d7a78e) to head (44fb0bc).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
+ Coverage   98.51%   99.18%   +0.67%     
==========================================
  Files          71       72       +1     
  Lines        6736     6766      +30     
==========================================
+ Hits         6636     6711      +75     
+ Misses         77       42      -35     
+ Partials       23       13      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shamaton shamaton merged commit 2dcdf8e into main Oct 15, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants