Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance based on the specified <paramref name="year"/>, <paramref name="week"/> and <paramref name="offset"/>.
 /// </summary>
 /// <param name="year">The year.</param>
 /// <param name="week">The week number.</param>
 /// <param name="offset">The offset.</param>
 public EssentialsWeek(int year, int week, TimeSpan offset)
 {
     WeekNumber = week;
     Year       = year;
     Start      = Iso8601Utils.FromWeekNumber(year, week, offset);
     End        = Start.GetEndOfWeek();
 }
Esempio n. 2
0
        public void FromWeekNumberRomance()
        {
            TimeZoneInfo romance = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time");

            DateTimeOffset week1 = Iso8601Utils.FromWeekNumber(2021, 1, romance);

            DateTimeOffset week12 = Iso8601Utils.FromWeekNumber(2021, 12, romance);
            DateTimeOffset week13 = Iso8601Utils.FromWeekNumber(2021, 13, romance);

            DateTimeOffset week43 = Iso8601Utils.FromWeekNumber(2021, 43, romance);
            DateTimeOffset week44 = Iso8601Utils.FromWeekNumber(2021, 44, romance);

            DateTimeOffset week52 = Iso8601Utils.FromWeekNumber(2021, 52, romance);

            Assert.AreEqual("2021-01-04T00:00:00+01:00", week1.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 1");
            Assert.AreEqual("2021-03-22T00:00:00+01:00", week12.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 12");
            Assert.AreEqual("2021-03-29T00:00:00+02:00", week13.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 13");
            Assert.AreEqual("2021-10-25T00:00:00+02:00", week43.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 43");
            Assert.AreEqual("2021-11-01T00:00:00+01:00", week44.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 44");
            Assert.AreEqual("2021-12-27T00:00:00+01:00", week52.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 52");
        }
Esempio n. 3
0
        public void FromWeekNumberUtc()
        {
            TimeZoneInfo utc = TimeZoneInfo.FindSystemTimeZoneById("UTC");

            DateTimeOffset week1 = Iso8601Utils.FromWeekNumber(2021, 1, utc);

            DateTimeOffset week12 = Iso8601Utils.FromWeekNumber(2021, 12, utc);
            DateTimeOffset week13 = Iso8601Utils.FromWeekNumber(2021, 13, utc);

            DateTimeOffset week43 = Iso8601Utils.FromWeekNumber(2021, 43, utc);
            DateTimeOffset week44 = Iso8601Utils.FromWeekNumber(2021, 44, utc);

            DateTimeOffset week52 = Iso8601Utils.FromWeekNumber(2021, 52, utc);

            Assert.AreEqual("2021-01-04T00:00:00+00:00", week1.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 1");
            Assert.AreEqual("2021-03-22T00:00:00+00:00", week12.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 12");
            Assert.AreEqual("2021-03-29T00:00:00+00:00", week13.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 13");
            Assert.AreEqual("2021-10-25T00:00:00+00:00", week43.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 43");
            Assert.AreEqual("2021-11-01T00:00:00+00:00", week44.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 44");
            Assert.AreEqual("2021-12-27T00:00:00+00:00", week52.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 52");
        }
Esempio n. 4
0
        public void FromWeekNumberOffset()
        {
            TimeSpan gmt1 = TimeSpan.FromHours(1);
            TimeSpan gmt2 = TimeSpan.FromHours(2);

            DateTimeOffset week1 = Iso8601Utils.FromWeekNumber(2021, 1, gmt1);

            DateTimeOffset week12 = Iso8601Utils.FromWeekNumber(2021, 12, gmt1);
            DateTimeOffset week13 = Iso8601Utils.FromWeekNumber(2021, 13, gmt2);

            DateTimeOffset week43 = Iso8601Utils.FromWeekNumber(2021, 43, gmt2);
            DateTimeOffset week44 = Iso8601Utils.FromWeekNumber(2021, 44, gmt1);

            DateTimeOffset week52 = Iso8601Utils.FromWeekNumber(2021, 52, gmt1);

            Assert.AreEqual("2021-01-04T00:00:00+01:00", week1.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 1");
            Assert.AreEqual("2021-03-22T00:00:00+01:00", week12.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 12");
            Assert.AreEqual("2021-03-29T00:00:00+02:00", week13.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 13");
            Assert.AreEqual("2021-10-25T00:00:00+02:00", week43.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 43");
            Assert.AreEqual("2021-11-01T00:00:00+01:00", week44.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 44");
            Assert.AreEqual("2021-12-27T00:00:00+01:00", week52.ToString(DateTimeSeconds, CultureInfo.InvariantCulture), "Week 52");
        }
 /// <summary>
 /// Initialize a new instance based on the specified <strong>ISO 8601</strong> <paramref name="year"/> and
 /// <paramref name="week"/>.
 /// </summary>
 /// <param name="year">The <strong>ISO 8601</strong> year of the week.</param>
 /// <param name="week">The <strong>ISO 8601</strong> week number.</param>
 public EssentialsDateWeek(int year, int week) : this(Iso8601Utils.FromWeekNumber(year, week).DateTime)
 {
 }
Esempio n. 6
0
 public static DateTimeOffset GetDateTimeOffsetFromIso8601Week(int year, int week)
 {
     return(Iso8601Utils.FromWeekNumber(year, week));
 }
Esempio n. 7
0
 public static DateTime GetDateTimeFromIso8601Week(int year, int week)
 {
     return(Iso8601Utils.FromWeekNumber(year, week).DateTime);
 }