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

6 days 9 hours 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

6 days 3 hours 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

6 days 1 hour 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

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

6 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

5 days 23 hours 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

5 days 8 hours 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

5 days 8 hours 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

5 days 8 hours 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

5 days 7 hours ago

In changed the code as said…

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

Image

ali_bahal

4 days 8 hours ago

hi, I'm sorry, did you find…

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

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

Hire Us!

Latest Releases

Wed, 05/24/2023 - 09:11
Gurux.DLMS.Net 9.0.2305.2401
Mon, 05/22/2023 - 15:00
gurux.dlms.cpp 20230522.1
Mon, 05/22/2023 - 10:07
Gurux.DLMS.AMI4 4.0.2305.2201
Tue, 05/16/2023 - 11:48
Gurux.DLMS.AMI4 4.0.2305.1601
Mon, 05/15/2023 - 13:32
Gurux.DLMS.AMI4 4.0.2305.1501

Open bugs

gurux.dlms.c
4
gurux.dlms.cpp
4
gurux.dlms.delphi
1
gurux.terminal.java
1

New forum topics

  • How do I define params for server.example?
  • Silvitra: Buy Atlanta
  • Triamterene: Effect Fast Purchase Delivery
  • Tetracycline: 2 Malaysia Price 250Mg
  • Zoloft: Order 100 Mg Rsnx9
More
RSS feed
Privacy FAQ GXDN Issues Contact
Follow Gurux on Twitter Follow Gurux on Linkedin