Exemple #1
0
        public void CreateWithTemplateValue()
        {
            // This is testing the Create call specifying the template directly, instead of the WithTemplate method
            var template = new YearMonth(2000, 6);
            var pattern  = YearMonthPattern.Create("yyyy", CultureInfo.InvariantCulture, template);

            Assert.AreEqual(template, pattern.TemplateValue);
            var parseResult = pattern.Parse("1990");

            Assert.True(parseResult.Success);
            Assert.AreEqual(new YearMonth(1990, 6), parseResult.Value);
        }
Exemple #2
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LongDatePattern?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LongTimePattern?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (MonthDayPattern?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (RFC1123Pattern?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ShortDatePattern?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ShortTimePattern?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (YearMonthPattern?.GetHashCode() ?? 0);
            return(hashCode);
        }
Exemple #3
0
        public void CreateWithCurrentCulture()
        {
            var yearMonth = new YearMonth(2017, 8);

            using (CultureSaver.SetCultures(Cultures.EnUs))
            {
                var pattern = YearMonthPattern.CreateWithCurrentCulture("yyyy/MM");
                Assert.AreEqual("2017/08", pattern.Format(yearMonth));
            }
            using (CultureSaver.SetCultures(Cultures.FrCa))
            {
                var pattern = YearMonthPattern.CreateWithCurrentCulture("yyyy/MM");
                Assert.AreEqual("2017-08", pattern.Format(yearMonth));
            }
        }
Exemple #4
0
        public void CreateWithSpecificCulture()
        {
            var pattern = YearMonthPattern.Create("yyyy/MM", Cultures.FrCa);

            Assert.AreEqual("2017-08", pattern.Format(new YearMonth(2017, 8)));
        }