summary refs log tree commit diff
path: root/crypto/src/asn1/x509
diff options
context:
space:
mode:
authorJozef Gajdos <jozef.gajdos@disig.sk>2022-08-02 10:39:55 +0200
committerJozef Gajdos <jozef.gajdos@disig.sk>2022-08-02 10:39:55 +0200
commitd41d40e206e002efec9fe96afd89b2dbd9ffdebf (patch)
tree642bb6a10641fc9cfd1a6f88f38b7f74d88c16ba /crypto/src/asn1/x509
parentMake nextUpdate nullable (diff)
downloadBouncyCastle.NET-ed25519-d41d40e206e002efec9fe96afd89b2dbd9ffdebf.tar.xz
Optimize constructors for Org.BouncyCastle.Asn1.X509.Time and Org.BouncyCastle.Asn1.Cms.Time.
Diffstat (limited to 'crypto/src/asn1/x509')
-rw-r--r--crypto/src/asn1/x509/Time.cs8
1 files changed, 3 insertions, 5 deletions
diff --git a/crypto/src/asn1/x509/Time.cs b/crypto/src/asn1/x509/Time.cs
index efdf63850..26c972904 100644
--- a/crypto/src/asn1/x509/Time.cs
+++ b/crypto/src/asn1/x509/Time.cs
@@ -35,17 +35,15 @@ namespace Org.BouncyCastle.Asn1.X509
          */
         public Time(DateTime date)
         {
-            string d = date.ToUniversalTime().ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture) + "Z";
+            DateTime d = date.ToUniversalTime();
 
-            int year = int.Parse(d.Substring(0, 4));
-
-            if (year < 1950 || year > 2049)
+            if (d.Year < 1950 || d.Year > 2049)
             {
                 time = new DerGeneralizedTime(d);
             }
             else
             {
-                time = new DerUtcTime(d.Substring(2));
+                time = new DerUtcTime(d);
             }
         }