Exemple #1
0
        public void ErinnTimeToString()
        {
            var time1 = new ErinnTime(DateTime.Parse("2015-01-01 00:00"));

            Assert.Equal("550-4-01 00:00", time1.ToString());
            Assert.Equal("0550-04-01 0:0", time1.ToString("yyyy-MM-dd H:m"));
            Assert.Equal("00:00 AM", time1.ToString("HH:mm tt"));

            Assert.Equal("01 Lughnasadh 550", time1.ToString("dd MMMM yyy"));
            ErinnTime.SetMonthNames("0", "1", "2", "3", "Foobar", "5", "6");
            Assert.Equal("01 Foobar 550", time1.ToString("dd MMMM yyy"));

            var time2 = new ErinnTime(DateTime.Parse("2015-01-01 23:59"));

            Assert.Equal("23:20 PM", time2.ToString("HH:mm tt"));
        }
Exemple #2
0
        /// <summary>
        /// Loads system and user localization files.
        /// </summary>
        public void LoadLocalization(BaseConf conf)
        {
            var language = conf.Localization.Language;
            var path     = Path.Combine("localization", language + ".po");

            Log.Info("Loading localization ({0})...", language);

            // Try user first
            try
            {
                Localization.Load(Path.Combine("user", path));
            }
            catch (FileNotFoundException)
            {
                // Try system second, if the file wasn't in user
                try
                {
                    Localization.Load(Path.Combine("system", path));
                }
                catch (FileNotFoundException)
                {
                    // Warn if language wasn't the default
                    if (language != "en-US")
                    {
                        Log.Warning("Localization file '{0}.po' not found.", language);
                    }
                }
            }

            ErinnTime.SetMonthNames(
                Localization.Get("Imbolic"),
                Localization.Get("Alban Eiler"),
                Localization.Get("Baltane"),
                Localization.Get("Alban Heruin"),
                Localization.Get("Lughnasadh"),
                Localization.Get("Alban Elved"),
                Localization.Get("Samhain")
                );
        }
Exemple #3
0
        public void ErinnTimeToString()
        {
            var time1 = new ErinnTime(DateTime.Parse("2015-01-01 00:00"));

            Assert.Equal("550-5-01 00:00", time1.ToString());
            Assert.Equal("0550-05-01 0:0", time1.ToString("yyyy-MM-dd H:m"));
            Assert.Equal("00:00 AM", time1.ToString("HH:mm tt"));

            Assert.Equal("01 Lughnasadh 550", time1.ToString("dd MMMM yyy"));
            ErinnTime.SetMonthNames("0", "1", "2", "3", "Foobar", "5", "6");
            Assert.Equal("01 Foobar 550", time1.ToString("dd MMMM yyy"));

            var time2 = new ErinnTime(DateTime.Parse("2015-01-01 23:59"));

            Assert.Equal("23:20 PM", time2.ToString("HH:mm tt"));

            var dt3 = DateTime.Parse("2016-06-26 00:00");

            for (int year = 0; year < 2; ++year)
            {
                for (int month = 0; month < 7; ++month)
                {
                    for (int day = 0; day < 40; ++day)
                    {
                        for (int hour = 0; hour < 24; ++hour)
                        {
                            for (int minute = 0; minute < 60; ++minute)
                            {
                                var time = new ErinnTime(dt3.AddMilliseconds((year * (7 * 40 * 24 * 60 * 1500)) + (month * (40 * 24 * 60 * 1500)) + (day * (24 * 60 * 1500)) + (hour * (60 * 1500)) + (minute * 1500)));
                                Assert.Equal(string.Format("{0}-{1}-{2:00} {3:00}:{4:00}", 628 + year, month + 1, day + 1, hour, minute), time.ToString());
                            }
                        }
                    }
                }
            }
        }