aboutsummaryrefslogtreecommitdiffstats
path: root/testing/mono/assume-UTC-if-no-TZ-set.patch
blob: ee89a3ad98eae283d77abd1abb85e98b09871c9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
From cf4e7339e31d19e6934d7b8130f82697212ea39e Mon Sep 17 00:00:00 2001
From: Marcin Cieslak <saper@saper.info>
Date: Sun, 7 Jun 2015 20:14:47 +0000
Subject: [PATCH] [corlib] Assume UTC if no $TZ set. Fixes #30360

Don't throw System.TimeZoneNotFoundException
if no $TZ is set and there is no /etc/localtime
or similar file.
---
 mcs/class/corlib/System/TimeZoneInfo.cs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/mcs/class/corlib/System/TimeZoneInfo.cs b/mcs/class/corlib/System/TimeZoneInfo.cs
index 717bfa7..6babee8 100644
--- a/mcs/class/corlib/System/TimeZoneInfo.cs
+++ b/mcs/class/corlib/System/TimeZoneInfo.cs
@@ -116,11 +116,11 @@ static TimeZoneInfo CreateLocal ()
 
 			try {
 				return FindSystemTimeZoneByFileName ("Local", "/etc/localtime");	
-			} catch {
+			} catch (TimeZoneNotFoundException) {
 				try {
 					return FindSystemTimeZoneByFileName ("Local", Path.Combine (TimeZoneDirectory, "localtime"));	
-				} catch {
-					return null;
+				} catch (TimeZoneNotFoundException) {
+					return Utc;
 				}
 			}
 		}