summary refs log tree commit diff
path: root/crypto/src/asn1/cms/Time.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/cms/Time.cs')
-rw-r--r--crypto/src/asn1/cms/Time.cs17
1 files changed, 6 insertions, 11 deletions
diff --git a/crypto/src/asn1/cms/Time.cs b/crypto/src/asn1/cms/Time.cs
index d113bfa2e..e5730245e 100644
--- a/crypto/src/asn1/cms/Time.cs
+++ b/crypto/src/asn1/cms/Time.cs
@@ -1,8 +1,6 @@
 using System;
 using System.Globalization;
 
-using Org.BouncyCastle.Asn1;
-
 namespace Org.BouncyCastle.Asn1.Cms
 {
     public class Time
@@ -20,13 +18,12 @@ namespace Org.BouncyCastle.Asn1.Cms
 		public Time(
             Asn1Object time)
         {
-            if (!(time is DerUtcTime)
-                && !(time is DerGeneralizedTime))
-            {
+            if (time == null)
+                throw new ArgumentNullException("time");
+            if (!(time is DerUtcTime) && !(time is DerGeneralizedTime))
                 throw new ArgumentException("unknown object passed to Time");
-            }
 
-			this.time = time;
+            this.time = time;
         }
 
 		/**
@@ -37,7 +34,7 @@ namespace Org.BouncyCastle.Asn1.Cms
         public Time(
             DateTime date)
         {
-            string d = date.ToString("yyyyMMddHHmmss") + "Z";
+            string d = date.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
 
 			int year = int.Parse(d.Substring(0, 4));
 
@@ -56,14 +53,12 @@ namespace Org.BouncyCastle.Asn1.Cms
         {
             if (obj == null || obj is Time)
                 return (Time)obj;
-
 			if (obj is DerUtcTime)
                 return new Time((DerUtcTime)obj);
-
 			if (obj is DerGeneralizedTime)
                 return new Time((DerGeneralizedTime)obj);
 
-			throw new ArgumentException("unknown object in factory: " + obj.GetType().Name, "obj");
+            throw new ArgumentException("unknown object in factory: " + obj.GetType().Name, "obj");
         }
 
 		public string TimeString