C# SetTimeZoneInformation doesn't work?

Questions about Wine on Linux
Locked
Cagnulein
Level 2
Level 2
Posts: 19
Joined: Sun Sep 20, 2009 8:32 am

C# SetTimeZoneInformation doesn't work?

Post by Cagnulein »

Hi everybody,
i'm trying to debug a problem on a SetTimeZoneInformation: in order to make the thing easier for me and for you I wrote a simple application written on C# .NET 2.0 that simply set the timezone.
I know that the bestway to set the timezone is to do it on the linux side, but i think it you should work in Wine too in order to have 100% compatibility of Windows software.

I attached here the source code and the executable.
You could try yourself: in the code i change the bias, but the time doesn't change.

This is the main part:

Code: Select all

            TimeZoneInformation timeZoneInformation = GetTimeZone();
            TimeZoneInformation a = timeZoneInformation;
            Console.WriteLine(a.bias);
            Console.WriteLine(DateTime.Now);
            a.bias = 120;
            a.standardName = "ciccio";
            SetTimeZone(a);
            timeZoneInformation = GetTimeZone();
            Console.WriteLine(a.bias);
            Console.WriteLine(DateTime.Now);
Attachments
TestSetTimeZone.zip
source and exe
(155.74 KiB) Downloaded 64 times
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: C# SetTimeZoneInformation doesn't work?

Post by DarkShadow44 »

On Windows the output is

Code: Select all

-60
19.01.2020 23:08:55
120
19.01.2020 23:08:55
So, where's the problem?
Cagnulein
Level 2
Level 2
Posts: 19
Joined: Sun Sep 20, 2009 8:32 am

Re: C# SetTimeZoneInformation doesn't work?

Post by Cagnulein »

Sorry, put this line

Code: Select all

            SetTimeZone(a);
+           CultureInfo.CurrentCulture.ClearCachedData();
            timeZoneInformation = GetTimeZone();
On windows you will have

Code: Select all

-60
20/01/2020 08:42:03
120
20/01/2020 05:42:03
instead on wine you will have

Code: Select all

-60
20/01/2020 08:42:03
120
20/01/2020 08:42:03
I put the new exe here.
Attachments
TestSetTimeZone.zip
(2.96 KiB) Downloaded 67 times
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: C# SetTimeZoneInformation doesn't work?

Post by DarkShadow44 »

Still have the same times on windows...
Cagnulein
Level 2
Level 2
Posts: 19
Joined: Sun Sep 20, 2009 8:32 am

Re: C# SetTimeZoneInformation doesn't work?

Post by Cagnulein »

DarkShadow44 wrote: Mon Jan 20, 2020 1:15 pm Still have the same times on windows...
On which windows' version are you trying it?
On Windows 10 this is the my result.
Attachments
Immagine.png
Immagine.png (9.18 KiB) Viewed 1474 times
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: C# SetTimeZoneInformation doesn't work?

Post by DarkShadow44 »

Using Win7. On Win10 it behaves like you said. Is this documented behavior?
Cagnulein
Level 2
Level 2
Posts: 19
Joined: Sun Sep 20, 2009 8:32 am

Re: C# SetTimeZoneInformation doesn't work?

Post by Cagnulein »

No, i've only saw an answer on StackOverflow about it :(
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: C# SetTimeZoneInformation doesn't work?

Post by DarkShadow44 »

Well, if it's reliable, wine could implement it. Where did you find that problem originally? In some program or something you made yourself?
Cagnulein
Level 2
Level 2
Posts: 19
Joined: Sun Sep 20, 2009 8:32 am

Re: C# SetTimeZoneInformation doesn't work?

Post by Cagnulein »

On a software that I wrote on my own.
Wine could use the source code that I've already attached as reference
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: C# SetTimeZoneInformation doesn't work?

Post by DarkShadow44 »

Or you could work around the issue to have it consistent across windows.
Cagnulein
Level 2
Level 2
Posts: 19
Joined: Sun Sep 20, 2009 8:32 am

Re: C# SetTimeZoneInformation doesn't work?

Post by Cagnulein »

i've alread worked around it, but i thought it could be useful for wine too to follow the behavior of windows
User avatar
DarkShadow44
Level 8
Level 8
Posts: 1207
Joined: Tue Nov 22, 2016 5:39 pm

Re: C# SetTimeZoneInformation doesn't work?

Post by DarkShadow44 »

Makes sense. Probably best to report it to https://bugs.winehq.org/
Locked