© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
8 replies
garrus_j

❔ DateTime help with NodaTime

So I receive timeseries data from an API which I then save in a db. The API delivers the data in hourly timespans, which are always using the Central European Standard Time zone. I want to save it in UTC format in the database, but daylight savings is giving me a real headache..
Take October 30th 2022, the data looks like this:

"Date": "2022-10-30T00:00:00",
      "Base": 1173.386,
      "TimeSpans": [
        {
          "TimeSpan": "00:00-01:00",
          "Value": 1030.94
        },
        {
          "TimeSpan": "01:00-02:00",
          "Value": 1009.4
        },
        {
          "TimeSpan": "02:00-02:00",
          "Value": 1006.71
        },
        {
          "TimeSpan": "dst",
          "Value": 1003.41
        },
        {
          "TimeSpan": "03:00-04:00",
          "Value": 984.24
        },
        {
          "TimeSpan": "04:00-05:00",
          "Value": 985.68
        },
        {
          "TimeSpan": "05:00-06:00",
          "Value": 990.94
        },
"Date": "2022-10-30T00:00:00",
      "Base": 1173.386,
      "TimeSpans": [
        {
          "TimeSpan": "00:00-01:00",
          "Value": 1030.94
        },
        {
          "TimeSpan": "01:00-02:00",
          "Value": 1009.4
        },
        {
          "TimeSpan": "02:00-02:00",
          "Value": 1006.71
        },
        {
          "TimeSpan": "dst",
          "Value": 1003.41
        },
        {
          "TimeSpan": "03:00-04:00",
          "Value": 984.24
        },
        {
          "TimeSpan": "04:00-05:00",
          "Value": 985.68
        },
        {
          "TimeSpan": "05:00-06:00",
          "Value": 990.94
        },


I'm using NodaTime to try and handle this. I parse a DateTime object using the Date and the second half of the TimeSpan, but this way I always end up with a double instance of 2022-10-30T02:00:00, and this will always be converted to 2022-10-30T01:00:00 UTC. What I need is for the first instance to become 2022-10-30T00:00:00 to be correct in UTC terms. Anyone have any smart ideas?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Need help with datetime
C#CC# / help
3y ago
help datetime
C#CC# / help
4y ago
✅ NodaTime JSON Serialization
C#CC# / help
2y ago
❔ Converting my project to NodaTime
C#CC# / help
3y ago