Search Unity

TimeZoneInfo error on android

Discussion in 'Scripting' started by peterbrinson, Jun 14, 2020.

  1. peterbrinson

    peterbrinson

    Joined:
    Jul 1, 2013
    Posts:
    63
    This code works in Windows and OSX, but on my Android I get an error. Thank you.

    Code (CSharp):
    1.  DateTime now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"));
    error:
    2020-06-14 12:38:34.167 16817-16851/? E/Unity: DirectoryNotFoundException: Could not find a part of the path "/usr/share/zoneinfo/Pacific Standard Time".
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0017d] in <c79628fadf574d3a8feae0871fad28ef>:0
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <c79628fadf574d3a8feae0871fad28ef>:0
    at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare)
    at System.IO.File.OpenRead (System.String path) [0x00000] in <c79628fadf574d3a8feae0871fad28ef>:0
    at System.TimeZoneInfo.FindSystemTimeZoneByFileName (System.String id, System.String filepath) [0x00002] in <c79628fadf574d3a8feae0871fad28ef>:0
    Rethrow as TimeZoneNotFoundException: Couldn't read time zone file /usr/share/
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
  3. peterbrinson

    peterbrinson

    Joined:
    Jul 1, 2013
    Posts:
    63
  4. UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    UDN_5c806b49-d8a0-4f67-a296-c12c91aa7396

    Joined:
    Jan 9, 2017
    Posts:
    152
  5. peterbrinson

    peterbrinson

    Joined:
    Jul 1, 2013
    Posts:
    63
    I don't remember well, but I believe I worked around it.