Skip to content

TimeZoneInfo StandardName, DisplayName changes #33037

Closed

Description

@cristina-dorotan

Steps to reproduce the issue
use Net Core 2.1 and Display StandardName and DisplayName on Windows os
use Net Core 3.1 and Display StandardName and DisplayName on Linux os

Expected behavior
We expect that the StandardNamas and DisplayNames to be the same from 2.1 to 3.1

Actual behavior
It seams that the behavior has changed from 2.1 to 3.1 on Linux os, the DisplayName is replaced by StandardName and vice versa.

Activity

  1. added
    untriaged
    on Mar 2, 2020
  2. danmoseley commented on Mar 2, 2020

    @danmoseley
    Contributor

    Can you give concrete examples? (Code and output before/after)

  3. cristina-dorotan commented on Mar 3, 2020

    @cristina-dorotan
    Author
            return TimeZoneInfo.GetSystemTimeZones().Select(
                    timezone => new TimezoneModel
                    {
                        DisplayName = $"({timezone.StandardName}) {timezone.Id}".Replace("_", " ")
                    })
                .ToList();
    

    Result in NET Core 2.2 Windows and Linux- using Docker:
    FROM nosinovacao/dotnet-sonar:19.09.0 as build
    The results are the same for both OS

    {
    "displayName": "((UTC-12:00) International Date Line West) Dateline Standard Time"
    },
    {
    "displayName": "((UTC-11:00) Co-ordinated Universal Time-11) UTC-11"
    },
    {
    "displayName": "((UTC-10:00) Aleutian Islands) Aleutian Standard Time"
    },
    {
    "displayName": "((UTC-10:00) Hawaii) Hawaiian Standard Time"
    },
    {
    "displayName": "((UTC-09:30) Marquesas Islands) Marquesas Standard Time"
    },
    {
    "displayName": "((UTC-09:00) Alaska) Alaskan Standard Time"
    },
    {
    "displayName": "((UTC-09:00) Co-ordinated Universal Time-09) UTC-09"
    },
    {
    "displayName": "((UTC-08:00) Baja California) Pacific Standard Time (Mexico)"
    },
    {
    "displayName": "((UTC-08:00) Co-ordinated Universal Time-08) UTC-08"
    }
    Same code, after upgrade to 3.1
    Using FROM nosinovacao/dotnet-sonar:latest as build
    Results are different on Windows vs Linux
    Results for Windows:

    {
    "displayName": "((UTC-12:00) International Date Line West) Dateline Standard Time"
    },
    {
    "displayName": "((UTC-11:00) Co-ordinated Universal Time-11) UTC-11"
    },
    {
    "displayName": "((UTC-10:00) Aleutian Islands) Aleutian Standard Time"
    },
    {
    "displayName": "((UTC-10:00) Hawaii) Hawaiian Standard Time"
    },
    {
    "displayName": "((UTC-09:30) Marquesas Islands) Marquesas Standard Time"
    },
    {
    "displayName": "((UTC-09:00) Alaska) Alaskan Standard Time"
    },
    {
    "displayName": "((UTC-09:00) Co-ordinated Universal Time-09) UTC-09"
    },
    {
    "displayName": "((UTC-08:00) Baja California) Pacific Standard Time (Mexico)"
    },
    {
    "displayName": "((UTC-08:00) Co-ordinated Universal Time-08) UTC-08"
    }
    Results from the Docker image(Linux):
    {
    "displayName": "(Dateline Standard Time) Dateline Standard Time"
    },
    {
    "displayName": "(UTC-11) UTC-11"
    },
    {
    "displayName": "(Aleutian Standard Time) Aleutian Standard Time"
    },
    {
    "displayName": "(Hawaiian Standard Time) Hawaiian Standard Time"
    },
    {
    "displayName": "(Marquesas Standard Time) Marquesas Standard Time"
    },
    {
    "displayName": "(Alaskan Standard Time) Alaskan Standard Time"
    },
    {
    "displayName": "(UTC-09) UTC-09"
    },
    {
    "displayName": "(Pacific Standard Time (Mexico)) Pacific Standard Time (Mexico)"
    },
    {
    "displayName": "(UTC-08) UTC-08"
    },

  4. danmoseley commented on Mar 4, 2020

    @danmoseley
    Contributor

    @tarekgh is this familiar?

  5. tarekgh commented on Mar 4, 2020

    @tarekgh
    Member

    This was intentional change 0663f87

    Why need to have the standard name match the display name? the display name is intended to be used for display purposes and shouldn't assume will change or match the standard names.

    @cristina-dorotan could you please clarify your scenario and why you need to have the 2 names match? Also, you shouldn't take any dependency on the display name as it can change and possibly can be displayed in different languages (even we don't support that today).

  6. tarekgh commented on Mar 4, 2020

    @tarekgh
    Member

    @cristina-dorotan I am closing this issue but feel free to respond back with any question or request and we'll be happy to assist you and reactivate if necessary.

  7. cristina-dorotan commented on Mar 5, 2020

    @cristina-dorotan
    Author

    @tarekgh @danmosemsft
    I opened the ticket because they are mixed up in Linux, NOT because StandardName is not equal with DisplayName.

    I am saying that StandardName in Windows != StandardName in Linux and

    This happens after the upgrade, as I mentioned before we are using nosinovacao/dotnet-sonar:latest as build.

    I would expect them to be the same in different Operating Systems as they were before the upgrade.

  8. tarekgh commented on Mar 6, 2020

    @tarekgh
    Member

    Thanks @cristina-dorotan for the clarification.

    I am seeing some weird things. I have a full Ubuntu 18.04 VM and I am not able to repro the issue on it. But, on my WSL2 with Ubuntu 18.04, I am seeing the names are wrong. I'll look more into that to figure out what is wrong.

  9. tarekgh commented on Mar 6, 2020

    @tarekgh
    Member

    CC @eerhardt who guessed correctly what could be the issue.

    @cristina-dorotan although the issue is not a direct regression in TimeZoneInfo, it is a side effect of the change dotnet/coreclr#25373 which avoid using the C or POSIX locales. What is happening is we use CultureInfo.CurrentUICulture to get the names of the Time Zones from the ICU library. I believe you have the LANG setting in your machine set to C.UTF-8 which is translated to en-US_posix locale in 2.x version and that locale used to work with ICU to get the nice names. In 3.1 we are mapping this POSIX locale to invariant which ICU not returning the nice names using this locale. By the way, this issue can repro on 2.1 if setting the UI culture to invariant.

    You have 2 easy options to work around this problem:

    1- either set the language to something different than C locale. do something like: export LANG=en_US.UTF-8 and then run your app. Or
    2- you can do this in the code before getting the names. something like the following:

                if (CultureInfo.CurrentUICulture.Name.Length == 0)
                {
                    CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
                     TimeZoneInfo.ClearCachedData();
                }
    
                // get the time zone names 

    @danmosemsft we'll try to have some nicer solution for this issue in 5.0 but the question is, do we need to service this in 3.1? we already have a simple workaround if needed.

  10. added and removed
    untriaged
    on Mar 6, 2020
  11. added this to the 5.0 milestone on Mar 6, 2020
  12. danmoseley commented on Mar 6, 2020

    @danmoseley
    Contributor

    @danmosemsft we'll try to have some nicer solution for this issue in 5.0 but the question is, do we need to service this in 3.1? we already have a simple workaround if needed.

    3.1 is an LTS release. To service we need a combination of significant/widespread customer impact and acceptably low risk. This sounds like mainly a display issue and with a good workaround. So it does not seem a servicing candidate.

  13. ghost locked as resolved and limited conversation to collaborators on Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions