public virtual void ShouldHandleArabicCulture() { ArabicTimeGlobalizationInfo strategy = new ArabicTimeGlobalizationInfo(); CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = new CultureInfo("ar-EG"); string formatted = strategy.FormatTime(new DateTime(1900, 1, 1, 14, 2, 0), new CustomTimeFormat("HH:mm:ss")); Assert.AreEqual("١٤:٠٢:٠٠", formatted); DateTime?result; Assert.IsTrue(strategy.TryParseTime("١٤:٠٢:٠٠", new CustomTimeFormat("HH:mm:ss"), null, out result)); Assert.AreEqual(new DateTime(1900, 1, 1, 14, 2, 0).TimeOfDay, result.Value.TimeOfDay); } finally { Thread.CurrentThread.CurrentCulture = currentCulture; } }
public virtual void ShouldMapGlobalCharacters() { ArabicTimeGlobalizationInfo strategy = new ArabicTimeGlobalizationInfo(); CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL"); string formatted = strategy.FormatTime(new DateTime(1900, 1, 1, 5, 6, 7), new CustomTimeFormat("HH:mm:ss")); Assert.AreEqual("٠٥:٠٦:٠٧", formatted); DateTime?result; Assert.IsTrue(strategy.TryParseTime("٠٥:٠٦:٠٧", new CustomTimeFormat("HH:mm:ss"), null, out result)); Assert.AreEqual(new DateTime(1900, 1, 1, 5, 6, 7).TimeOfDay, result.Value.TimeOfDay); } finally { Thread.CurrentThread.CurrentCulture = currentCulture; } }
public virtual void ShouldHandleArabicCulture() { ArabicTimeGlobalizationInfo strategy = new ArabicTimeGlobalizationInfo(); CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = new CultureInfo("ar-EG"); string formatted = strategy.FormatTime(new DateTime(1900, 1, 1, 14, 2, 0), new CustomTimeFormat("HH:mm:ss")); Assert.AreEqual("١٤:٠٢:٠٠", formatted); DateTime? result; Assert.IsTrue(strategy.TryParseTime("١٤:٠٢:٠٠", new CustomTimeFormat("HH:mm:ss"), null, out result)); Assert.AreEqual(new DateTime(1900, 1, 1, 14, 2, 0).TimeOfDay, result.Value.TimeOfDay); } finally { Thread.CurrentThread.CurrentCulture = currentCulture; } }
public virtual void ShouldMapGlobalCharacters() { ArabicTimeGlobalizationInfo strategy = new ArabicTimeGlobalizationInfo(); CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL"); string formatted = strategy.FormatTime(new DateTime(1900, 1, 1, 5, 6, 7), new CustomTimeFormat("HH:mm:ss")); Assert.AreEqual("٠٥:٠٦:٠٧", formatted); DateTime? result; Assert.IsTrue(strategy.TryParseTime("٠٥:٠٦:٠٧", new CustomTimeFormat("HH:mm:ss"), null, out result)); Assert.AreEqual(new DateTime(1900, 1, 1, 5, 6, 7).TimeOfDay, result.Value.TimeOfDay); } finally { Thread.CurrentThread.CurrentCulture = currentCulture; } }