Skip to main content
Home
for DLMS smart meters
Open source solutions for DLMS smart metering

Main navigation

  • Home
  • Products
  • About us
  • Open Source
  • Community
  • Forum
  • Downloads
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Forums
  3. Profile Generic Row Dates Are Affected By Local PCs DST Settings What May Result In Incorrect Dates

Profile generic row dates are affected by local PCs DST settings what may result in incorrect dates

Forum Rules

Before commenting read Forum rules

Don't comment the topic if you have a new question.

You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.

By rdk1 , 25 October, 2020
Forums
Gurux.DLMS

Hello,

Meter has no DST adjustment and always uses UTC+2 timezone. When I read historical data, only the first record has the correct time offset, other rows are affected by local PCs settings.

10/23/2020 11:00:00 PM +02:00 //meter timezone, correct
10/24/2020 1:00:00 AM +03:00 //local
10/24/2020 2:00:00 AM +03:00
10/24/2020 3:00:00 AM +03:00
10/24/2020 4:00:00 AM +03:00

If I read the same data on a PC with no DST adjustment I will get the correct data:

Meter time (UTC): 2020-10-25 04:38:13

Date (UTC) / Value
10/24/2020 11:00:00 PM > 5012072.8 //ok
10/25/2020 12:00:00 AM > 4910510.5 /ok
10/25/2020 1:00:00 AM > 4992696.8
10/25/2020 2:00:00 AM > 4980169.9
10/25/2020 3:00:00 AM > 5194268.9
10/25/2020 4:00:00 AM > 5313574.7 <- all good

But if I read the same rows on a PC with DST adjustment:

Meter time (UTC): 2020-10-25 04:37:14

Date (UTC) / Value
10/24/2020 11:00:00 PM > 5012072.8 //ok
10/25/2020 1:00:00 AM > 4910510.5 //1-hour ahead
10/25/2020 2:00:00 AM > 4992696.8
10/25/2020 3:00:00 AM > 4980169.9
10/25/2020 4:00:00 AM > 5194268.9
10/25/2020 5:00:00 AM > 5313574.7 <- 1-hour ahead, incorrect, meter time is only 4:37

Is there a reason why only the first row is in the meters timezone and other rows use local dates?
https://github.com/Gurux/Gurux.DLMS.Net/blob/b01e62ecf2f1d6940df6ba2997…

Shouldn't the date be always in the same timezone as the meter has?

rdk1

5 years 7 months ago

Update on this:

Update on this:

Simply replacing local DateTime (dt.Value.LocalDateTime) with the meters DateTimeOffset (dt.Value) will fix the issue and let us have the original date and correctly convert it to UTC or local time if required.

Meter | UTC | Local
10/25/2020 12:00:00 AM +02:00 | 2020-10-24 22:00:00 | 2020-10-25 01:00:00 / "+3"
10/25/2020 1:00:00 AM +02:00 | 2020-10-24 23:00:00 | 2020-10-25 02:00:00 / "+3"
10/25/2020 2:00:00 AM +02:00 | 2020-10-25 00:00:00 | 2020-10-25 03:00:00 / "+3"
10/25/2020 3:00:00 AM +02:00 | 2020-10-25 01:00:00 | 2020-10-25 03:00:00 / "+2"
10/25/2020 4:00:00 AM +02:00 | 2020-10-25 02:00:00 | 2020-10-25 04:00:00 / "+2"

Profile picture for user Kurumi

Kurumi

5 years 7 months ago

Hi,

Hi,

Is date-time field zero after the first row in your meter? Is this causing the problem?

BR,
Mikko

rdk1

5 years 7 months ago

Yes, only the first row

Yes, only the first row contains the date (meter is ISKRA MT880)

Row [0] column [0]: System.Byte[]
Row [1] column [0]: null
Row [2] column [0]: null
Row [3] column [0]: null
Row [4] column [0]: null

It is not causing problems as you handle such cases by increasing previous date by profile capture period.

But, for some reason, you don't keep the last date in meter timezone (only first date), but convert it to local time (lastDate = dt.Value.LocalDateTime;)

10/23/2020 11:00:00 PM +02:00 //meter timezone, correct
10/24/2020 1:00:00 AM +03:00 // converted to local

This makes it dependent on local PCs DST and when DST change happens local time is shifted back/forward and correlation with the original time is lost.

It would be more explicit to have all dates in meter timezone and convert them to UTC/local later when you need to display it to the user.

Profile picture for user Kurumi

Kurumi

5 years 7 months ago

Hi,

Hi,

Thank you for this information. Now I know the reason and I'll need to think about this a little bit. We'll talk about this and how to solve this.

There are only a few meter manufacturers that are saving bytes and ignore the date-time field after the first row. This makes testing a little more easier.

BR,
Mikko

Profile picture for user Kurumi

Kurumi

5 years 7 months ago

Hi,

Hi,

This is fixed to a new version from GXDLMSDirector. Let me know if you have any problems.

BR,
Mikko

rdk1

5 years 7 months ago

Hello,

Hello,

Thank you for a quick update, but it seems that dates are still inconsistent as original timezone is lost.

1. https://github.com/Gurux/Gurux.DLMS.Net/blob/master/Development/Objects…
lastDate = dt.Value.DateTime;
you keep the date, but timezone/offset information is lost here

2. https://github.com/Gurux/Gurux.DLMS.Net/blob/master/Development/Objects…
GXDateTime(DateTime value) will call GXDateTime(DateTime value, TimeZoneInfo timeZone) with no timezone info and will calculate offset from local time TimeZoneInfo.Local.GetUtcOffset(value)

This will produce the following results:
10/24/2020 4:30:00 AM +02:00 //1st record
10/24/2020 4:45:00 AM +03:00 //2nd record has meter time, but uses local timezone

And DST:
10/25/2020 2:30:00 AM +03:00 //UTC 11:30:00 PM
10/25/2020 2:45:00 AM +03:00 //UTC 11:45:00 PM
10/25/2020 3:00:00 AM +02:00 //UTC 1:00:00 AM <-wrong
10/25/2020 3:15:00 AM +02:00 //UTC 1:15:00 AM

This can be solved by using the same DateTimeOffset to keep the last date and preserve the original meters timezone:

GXDateTime dt = (GXDateTime)row[pos];
lastDate = dt.Value;

and dates can be correctly converted to UTC/Local timezone

10/25/2020 1:45:00 AM +02:00 | UTC 2020-10-24 23:45:00
10/25/2020 2:00:00 AM +02:00 | UTC 2020-10-25 00:00:00
10/25/2020 2:15:00 AM +02:00 | UTC 2020-10-25 00:15:00
10/25/2020 2:30:00 AM +02:00 | UTC 2020-10-25 00:30:00
10/25/2020 2:45:00 AM +02:00 | UTC 2020-10-25 00:45:00
10/25/2020 3:00:00 AM +02:00 | UTC 2020-10-25 01:00:00
10/25/2020 3:15:00 AM +02:00 | UTC 2020-10-25 01:15:00

Profile picture for user Kurumi

Kurumi

5 years 7 months ago

Hi,

Hi,

So, you are saying that this will work for you if lastDate is changed to DateTimeOffset? Like this
DateTimeOffset lastDate = DateTime.MinValue;

What time zone you are using in your PC and the meter? We'll check this also with those time zones.

BR,
Mikko

rdk1

5 years 7 months ago

Hello,

Hello,

Yes, if you keep the date in DateTimeOffset and use dt.Value as lastValue the correct timezone offset will be preserved.

In fact, it all depends on how you initialize GXDateTime - passing DateTimeOffset will use the date and offset from it, but passing DateTime with no offset information will use local PCs default timezone and is dependent on PCs DST settings

10/23/2020 11:00:00 PM +02:00 //meter timezone, correct
10/24/2020 1:00:00 AM +03:00 //GXDateTime from DateTime with no offset, uses local PC timezone

Profile picture for user Kurumi

Kurumi

5 years 7 months ago

Hi,

Hi,

This is changed and a new version is released. A new version from GXDLMSDirector is released later today.

BR,
Mikko

  • Create new account
  • Reset your password

Hire Us!

Latest Releases

  • Tue, 06/09/2026 - 11:16
    gurux.dlms.java 4.0.95
  • Tue, 06/09/2026 - 10:03
    Gurux.DLMS.Python 1.0.199
  • Mon, 06/08/2026 - 13:39
    gurux.dlms.cpp 9.0.2606.0801
  • Mon, 06/01/2026 - 10:15
    gurux.dlms.cpp 9.0.2606.0101
  • Thu, 05/28/2026 - 16:06
    gurux.dlms.java 4.0.94

New forum topics

  • Error reading L&G Meter
  • Pass a TCP Client to GXNet
  • Australian EDMI Mk10D (Essential Energy area)
  • Strange mix of data notificiation vs get response
  • DLMS Connection
More

Who's new

  • Tuanhgg
  • Adel
  • charnon
  • Paddles
  • Miguel Ángel
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin