summary refs log tree commit diff
path: root/crypto/src/asn1/DerGeneralizedTime.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/asn1/DerGeneralizedTime.cs')
-rw-r--r--crypto/src/asn1/DerGeneralizedTime.cs14
1 files changed, 9 insertions, 5 deletions
diff --git a/crypto/src/asn1/DerGeneralizedTime.cs b/crypto/src/asn1/DerGeneralizedTime.cs

index 6700b9016..b224ebe42 100644 --- a/crypto/src/asn1/DerGeneralizedTime.cs +++ b/crypto/src/asn1/DerGeneralizedTime.cs
@@ -27,7 +27,7 @@ namespace Org.BouncyCastle.Asn1 return (DerGeneralizedTime)obj; } - throw new ArgumentException("illegal object in GetInstance: " + obj.GetType().Name, "obj"); + throw new ArgumentException("illegal object in GetInstance: " + Platform.GetTypeName(obj), "obj"); } /** @@ -83,7 +83,11 @@ namespace Org.BouncyCastle.Asn1 public DerGeneralizedTime( DateTime time) { +#if PORTABLE + this.time = time.ToUniversalTime().ToString(@"yyyyMMddHHmmss\Z"); +#else this.time = time.ToString(@"yyyyMMddHHmmss\Z"); +#endif } internal DerGeneralizedTime( @@ -200,7 +204,7 @@ namespace Org.BouncyCastle.Asn1 string d = time; bool makeUniversal = false; - if (d.EndsWith("Z")) + if (Platform.EndsWith(d, "Z")) { if (HasFractionalSeconds) { @@ -219,7 +223,7 @@ namespace Org.BouncyCastle.Asn1 if (HasFractionalSeconds) { - int fCount = d.IndexOf("GMT") - 1 - d.IndexOf('.'); + int fCount = Platform.IndexOf(d, "GMT") - 1 - d.IndexOf('.'); formatStr = @"yyyyMMddHHmmss." + FString(fCount) + @"'GMT'zzz"; } else @@ -263,11 +267,11 @@ namespace Org.BouncyCastle.Asn1 * NOTE: DateTime.Kind and DateTimeStyles.AssumeUniversal not available in .NET 1.1 */ DateTimeStyles style = DateTimeStyles.None; - if (format.EndsWith("Z")) + if (Platform.EndsWith(format, "Z")) { try { - style = (DateTimeStyles)Enum.Parse(typeof(DateTimeStyles), "AssumeUniversal"); + style = (DateTimeStyles)Enums.GetEnumValue(typeof(DateTimeStyles), "AssumeUniversal"); } catch (Exception) {