Skip to main content
Home
for DLMS smart meters

Main navigation

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

Breadcrumb

  1. Home
  2. Node
  3. Error On Parsing Jalali Date (Persian)

Error On Parsing Jalali Date (Persian)

By ali_bahal, 21 May, 2023
Forums
Gurux.DLMS

hi, in recent update of gurux , It can't Parse Persian date Correctly . in previous versions ,it was working greatly.

it has error on C# version and GxDlmsDirector.

Packet examples :

TX: 7E A0 1C 00 02 76 71 03 54 A8 19 E6 E6 00 C0 01 C1 00 08 00 00 01 00 00 FF 02 00 60 1A 7E
13:49:30
RX: 7E A0 21 03 00 02 76 71 74 82 BD E6 E7 00 C4 01 C1 00 09 0C 05 7A 02 1F 07 0D 31 17 00 FF 2E 00 62 F2 7E

now it gives Error :
Year, Month and day parameters describe an un-representable DateTime.

at System.DateTime.DateToTicks(Int32 year, Int32 month, Int32 day)
at System.DateTime..ctor(Int32 year, Int32 month, Int32 day, Int32 hour, Int32 minute, Int32 second, Int32 millisecond)
at Gurux.DLMS.Internal.GXCommon.GetDateTime(GXDLMSSettings settings, GXByteBuffer buff, GXDataInfo info)
at Gurux.DLMS.Internal.GXCommon.GetData(GXDLMSSettings settings, GXByteBuffer data, GXDataInfo info)
at Gurux.DLMS.GXDLMSClient.ChangeType(GXByteBuffer value, DataType type, Boolean useUtc)

ali_bahal

1 week 6 days ago

I think the problem raises…

I think the problem raises for month with 31 days . for example in above packets, in Persian 2nd month have 31 days and raises error. but other dates works greatly.

do you have any Idea, what we can do or is there anything that you can change in code ?

ali_bahal

1 week 6 days ago

I you can add Calendar to…

If you can add Calendar to GXDLMSSettings class and use below constructor of DateTime :

public DateTime(int year, int month, int day, int hour, int minute, int second, Calendar calendar)

that has calendar in in Conversion, I think all the problems will be solved

Profile picture for user Kurumi

Kurumi

1 week 6 days ago

Hi, No changes have been…

Hi,

No changes have been made to the date and time for a long time. Application is using the default calendar when the date-time is read from the meter.

The date is Yekshanbeh: 31. Ordibehesht 1402. Is that correct?
What is your time zone?

BR,
Mikko

ali_bahal

1 week 6 days ago

Yes, it.'s correct date…

Yes, it.'s correct date.
Timezome is : +3:30 Tehran

Is there any way to change calendar (set) for this?

Profile picture for user Kurumi

Kurumi

1 week 5 days ago

Hi, Calendar settings are…

Hi,

Calendar settings are defined in Windows and correct settings are given as a parameter. You can try to change settings from the Windows regional settings.

Are you using Windows 10 or 11? The same environment is installed and I believe that this can be fixed if it can be repeated.

BR,

Mikko

ali_bahal

1 week 5 days ago

No we are using windows…

No we are using windows server 2012, and I need to set gurux calendar from code. Setting current thread culture also don't slove the problem.
Any ideas will be appreciated.

ali_bahal

1 week 5 days ago

hi, Is it possible for you…

hi,
Is it possible for you to use DateTime overloads with calendar input in GxCommon ?
I mean use :
new DateTime(year, month, day, hours, minutes, seconds, milliseconds,Thread.CurrentThread.CurrentCulture.Calendar)

instead of :
new DateTime(year, month, day, hours, minutes, seconds, milliseconds)

or :
new DateTime(year, month, day, hours, minutes, seconds, milliseconds, Thread.CurrentThread.CurrentCulture.Calendar, DateTimeKind.Local)

instead of :
new DateTime(year, month, day, hours, minutes, seconds, milliseconds, DateTimeKind.Local)

Profile picture for user Kurumi

Kurumi

1 week 5 days ago

Hi, This doesn't help when…

Hi,

This doesn't help when you are reading data from the meter because it's not possible to set the calendar for the GXDLMSClient.

If you run dotnet --version what is the output?

BR,
Mikko

ali_bahal

1 week 5 days ago

there is no need to set…

there is no need to set calendar for the GXDLMSClient. we can use custume Culture class that has calendar as needed, and set for thread culture. but because you use this overloads of "new DateTime" that does not have Calendar in there inputs,then .net does not use thread calendar for them.

dotnet --version
7.0.203

ali_bahal

1 week 5 days ago

In changed the code as said…

In changed the code as I said above, and the code worked greatly

Image

ali_bahal

1 week 4 days ago

hi, I'm sorry, did you find…

hi,
I'm sorry, did you find any solution for this problem ? or have any idea ?

ali_bahal

6 days 4 hours ago

Hi, I would like to know if…

Hi, I would like to know if you plan on implementing the changes I suggested in GxCommon. I would appreciate it if you could let me know.

I believe that changing the method as I proposed will not have any side effects on your code, since there is no calendar setting in GXDLMSClient. Therefore, your code uses the system's default calendar. Changing the code as follows:

new DateTime(year, month, day, hours, minutes, seconds, milliseconds, Thread.CurrentThread.CurrentCulture.Calendar)

instead of:

new DateTime(year, month, day, hours, minutes, seconds, milliseconds)

in GxCommon should be fine. If you have any comments on this, I would appreciate your feedback.

If this change is applied to the source version, I would be able to use your later updates more easily. Thank you in advance!

Profile picture for user Kurumi

Kurumi

6 days 3 hours ago

Hi, Sorry to say, but it's…

Hi,

Sorry to say, but it's not s simple. This needs a lot of testing before it can be released.
Different time zones and localizations might cause really nasty problems.

It seems to work and it should be on the next release, but I can't say anything for sure before the tests are over.

BR,

Mikko

ali_bahal

4 days 23 hours ago

Thank you. I would…

Thank you.
I would appreciate it if you could let me know the result.

Profile picture for user Kurumi

Kurumi

3 days ago

Hi, This can be added for…

Hi,

This can be added for the next release. It's released during the next week.

BR,
Mikko

ali_bahal

2 days 21 hours ago

Hi, thank you in advance.

Hi, thank you in advance.

Profile picture for user Kurumi

Kurumi

2 days 2 hours ago

Hi, This is improved for the…

Hi,

This is improved for the GXDLMSDirector version 9.0.2306.0201.

BR,
Mikko

  • Log in or register to post comments
  • Create new account
  • Reset your password

Hire Us!

Latest Releases

Fri, 06/02/2023 - 14:13
GXDLMSDirector 9.0.2306.0201
Fri, 06/02/2023 - 13:51
Gurux.DLMS.Net 9.0.2306.0201
Fri, 06/02/2023 - 10:33
Gurux.DLMS.AMI4 4.0.2306.0201
Thu, 06/01/2023 - 16:39
Gurux.DLMS.AMI4 4.0.2306.0101
Thu, 06/01/2023 - 15:25
gurux.dlms.cpp 20230601.1

Open bugs

gurux.dlms.c
4
gurux.dlms.cpp
3
gurux.dlms.delphi
1

New forum topics

  • Optical port
  • Unable to connect - Unhandled exception.
  • Reading objects in US Association
  • Error when trying to read meter with GXDLMSDirector.
  • Meter without user
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin