Conversation
…booleans to bool? - Add JSON converter files for Unix timestamps, ISO dates, enabled/disabled strings, and true/false strings - Convert all Unix timestamp fields (long/long?) to DateTimeOffset/DateTimeOffset? with NullableUnixTimestampConverter - Convert all ISO date string fields (string?) to DateTimeOffset? with NullableDateTimeOffsetDateConverter - Convert enabled/disabled string fields to bool? with EnabledDisabledConverter - Convert true/false string bool fields to bool? with StringBoolConverter - Update ChargingSession start_time/end_time (non-nullable) to DateTimeOffset with UnixTimestampConverter - Preserve ChargingSession.Duration and ChargeTime as long (duration in seconds, not timestamps) - Update all IEnphaseClient and EnphaseClient method signatures to use DateTimeOffset instead of long/string for timestamps/dates - Update EnphaseClient to serialize DateTimeOffset params correctly (ToUnixTimeSeconds for timestamps, yyyy-MM-dd for dates) - Update tests to use DateTimeOffset values and fix assertions for bool? fields - Update approved API snapshot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Shane32 <6377684+Shane32@users.noreply.github.com>
… string fields Agent-Logs-Url: https://github.com/Shane32/EnphaseAPI/sessions/fae8bde7-5543-4fab-a43e-f80566df77cc Co-authored-by: Shane32 <6377684+Shane32@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update API to use DateTimeOffset for date fields
Make API .NET-first: DateTimeOffset for timestamps/dates, bool for string-encoded booleans
Mar 31, 2026
Shane32
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All date, timestamp, and boolean fields in the API models used raw primitive types (
long,string,bool?) mirroring the JSON wire format. This converts them to proper .NET types with bidirectional JSON conversion handled via[JsonConverter]attributes on the model properties.New JSON Converters (
Project/JsonConverters/)UnixTimestampConverter/NullableUnixTimestampConverterlong(Unix seconds)DateTimeOffset/DateTimeOffset?DateTimeOffsetDateConverter/NullableDateTimeOffsetDateConverter"YYYY-MM-DD"stringDateTimeOffset?(midnight UTC)EnabledDisabledConverter"enabled"/"disabled"bool?StringBoolConverter"true"/"false"bool?All converters throw
JsonExceptionon unrecognized values.Model field changes
long?unix timestamp fields →DateTimeOffset?string?ISO date fields →DateTimeOffset?ChargingSession.StartTime/EndTime(non-nullable) →DateTimeOffsetChargingSession.Duration/ChargeTimepreserved aslong— these are durations in seconds, not timestampsBatterySettings.ChargeFromGrid,EnergyIndependence→bool?StormGuardSettings.StormGuardStatus→bool?(viaEnabledDisabledConverter)StormGuardSettings.StormAlert→bool?(viaStringBoolConverter, API returns"false"string)UpdateBatterySettingsRequest.EnergyIndependence→bool?(serializes back as"enabled"/"disabled")Client method signature changes
All
long/long?timestamp parameters andstring/string?date parameters replaced withDateTimeOffset/DateTimeOffset?. Conversion is done internally inEnphaseClient:Internally, timestamp params use
.ToUnixTimeSeconds()and date params use.ToString("yyyy-MM-dd")when building query strings.