Example #1
0
            public void BackAndForth_UserTzIn()
            {
                long         epoch = 13912786171000L; // GMT: Sat, 01 Feb 2014 18:16:57 GMT
                DateTime     utc   = UnixEpoch.AddMilliseconds(epoch);
                TimeZoneInfo tz    = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time");
                DateTime     user  = tz.ConvertFromUtc(utc);
                var          html  = CreateHtmlHelper(new ViewDataDictionary());

                html.SetTimezone(tz);
                var result   = SrkHtmlExtensions.JsDate(html, user);
                var expected = "new Date(13912786171000)";

                Assert.AreEqual(expected, result.ToString());
            }
Example #2
0
            public void UserIsRomance_ArgIsUtc_ResultIsRomance()
            {
                Thread.CurrentThread.CurrentCulture = TestCulture1;
                TimeZoneInfo tz       = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time");
                DateTime     source   = new DateTime(2013, 1, 29, 13, 28, 21, 1, DateTimeKind.Utc);
                DateTime     romance  = tz.ConvertFromUtc(source);
                string       expected = "<time datetime=\"2013-01-29T13:28:21.0010000Z\" title=\"29/01/2013 14:28:21\" class=\"past not-today display-time\">14:28:21</time>";
                var          html     = CreateHtmlHelper(new ViewDataDictionary());

                html.SetTimezone(tz);

                var result = SrkHtmlExtensions.DisplayTime(html, source);

                Assert.AreEqual(expected, result.ToString());
            }
Example #3
0
            public void RomanceTz_ArgIsUtc_ResultIsRomance()
            {
                TimeZoneInfo tz     = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time");
                DateTime     orig   = new DateTime(2013, 1, 29, 13, 28, 21, 1, DateTimeKind.Utc);
                DateTime     source = tz.ConvertFromUtc(orig);
                var          html   = CreateHtmlHelper(new ViewDataDictionary());

                html.SetTimezone(tz);

                DateTime utcResult;
                var      result = SrkHtmlExtensions.GetUserDate(html, source, out utcResult);

                Assert.AreEqual(source, result, "wrong user result");
                Assert.AreEqual(orig, utcResult, "wrong UTC result");
            }
Example #4
0
            public void UserIsRomance_ArgIsLocal_ResultIsRomance()
            {
                Thread.CurrentThread.CurrentCulture = TestCulture1;
                TimeZoneInfo tz      = TimeZoneInfo.FindSystemTimeZoneById("Romance Standard Time");
                var          localTz = TimeZoneInfo.Local;
                DateTime     orig    = new DateTime(2013, 1, 29, 13, 28, 21, 1, DateTimeKind.Utc);
                DateTime     source  = orig.ToLocalTime();
                DateTime     romance = tz.ConvertFromUtc(source);

                Debug.Assert(source.Kind == DateTimeKind.Local);
                string expected = "<time datetime=\"2013-01-29T" + orig.Hour + ":28:21.0010000Z\" title=\"29 January 2013\" class=\"past not-today display-date\">29 January 2013</time>";
                var    html     = CreateHtmlHelper(new ViewDataDictionary());

                html.SetTimezone(tz);

                var result = SrkHtmlExtensions.DisplayDate(html, source);

                Assert.AreEqual(expected, result.ToString());
            }