Skip to content

Conversation

@swhitty
Copy link
Owner

@swhitty swhitty commented Jul 20, 2025

Adds DateEncoding/DecodingStrategy allowing for dates to be encoded using alternate formats by setting the strategy.

The (existing) default strategy casts to Any leaving the instance unchanged:

var encoder = KeyValueEncoder()
encoder.dateEncodingStrategy = .date

// Date()
let any = try encoder.encode(Date())

ISO8601 compatible strings can be used:

encoder.dateEncodingStrategy = .iso8601()

// "1970-01-01T00:00:00Z"
let any = try encoder.encode(Date(timeIntervalSince1970: 0))

@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.89%. Comparing base (f2058a2) to head (c584af0).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #14   +/-   ##
=======================================
  Coverage   99.89%   99.89%           
=======================================
  Files           3        3           
  Lines         951      983   +32     
=======================================
+ Hits          950      982   +32     
  Misses          1        1           

☔ 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.

@swhitty swhitty force-pushed the DateEncodingStrategy branch from e746b58 to af37715 Compare July 20, 2025 03:58
@swhitty swhitty force-pushed the DateEncodingStrategy branch from af37715 to c584af0 Compare July 20, 2025 04:00
@swhitty swhitty merged commit 3d6ca2b into main Jul 20, 2025
16 checks passed
@swhitty swhitty deleted the DateEncodingStrategy branch July 20, 2025 04:03
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.

3 participants