File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed
Parse/Internal/PlatformHooks Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -150,12 +150,17 @@ public string DeviceType {
150150
151151 public string DeviceTimeZone {
152152 get {
153- TimeSpan utcOffset = TimeZoneInfo . Local . BaseUtcOffset ;
154- return String . Format ( "GMT{0}{1}:{2:d2}" ,
155- offset . TotalSeconds < 0 ? "-" : "+" ,
156- Math . Abs ( offset . Hours ) ,
157- Math . Abs ( offset . Minutes )
158- ) ;
153+ // We need the system string to be in english so we'll have the proper key in our lookup table.
154+ var culture = Thread . CurrentThread . CurrentCulture ;
155+ Thread . CurrentThread . CurrentCulture = CultureInfo . InvariantCulture ;
156+ string windowsName = TimeZoneInfo . Local . StandardName ;
157+ Thread . CurrentThread . CurrentCulture = culture ;
158+
159+ if ( ParseInstallation . TimeZoneNameMap . ContainsKey ( windowsName ) ) {
160+ return ParseInstallation . TimeZoneNameMap [ windowsName ] ;
161+ } else {
162+ return null ;
163+ }
159164 }
160165 }
161166
Original file line number Diff line number Diff line change @@ -87,12 +87,16 @@ public string DeviceType {
8787
8888 public string DeviceTimeZone {
8989 get {
90- TimeSpan utcOffset = TimeZoneInfo . Local . BaseUtcOffset ;
91- return String . Format ( "GMT{0}{1}:{2:d2}" ,
92- offset . TotalSeconds < 0 ? "-" : "+" ,
93- Math . Abs ( offset . Hours ) ,
94- Math . Abs ( offset . Minutes )
95- ) ;
90+ try {
91+ string windowsName = TimeZoneInfo . Local . StandardName ;
92+ if ( ParseInstallation . TimeZoneNameMap . ContainsKey ( windowsName ) ) {
93+ return ParseInstallation . TimeZoneNameMap [ windowsName ] ;
94+ } else {
95+ return null ;
96+ }
97+ } catch ( TimeZoneNotFoundException ) {
98+ return null ;
99+ }
96100 }
97101 }
98102
You can’t perform that action at this time.
0 commit comments