Example #1
0
        public void Update(object sender, EventArgs args)
        {
            var wTracker = sender as WeatherDataTracker;

            _weatherData = wTracker?.wData;
            if (_weatherData != null)
            {
                _dateCalculated = UnixTimestampConverter.UnixTimestampToDateTime(_weatherData.DateCalculated);
                _sunrise        = UnixTimestampConverter.UnixTimestampToDateTime(_weatherData.SystemData.Sunrise);
                _sunset         = UnixTimestampConverter.UnixTimestampToDateTime(_weatherData.SystemData.Sunset);
                Display();
            }
        }
Example #2
0
        // Numeric 333
        private void HandleRplTopicWhoTime(object sender, MessageEventArgs ev)
        {
            Debug.Print("Channel.HandleRplTopicWhoTime: args='{0}'", string.Join("','", ev.Message.Args));

            try {
                TopicSetBy = new NickUserHost(ev.Message.Args[1]);
                Debug.Print("Channel.HandleRplTopicWhoTime: topic set by '{0}'", _topicSetBy);
            }
            catch (Exception e) {
                Debug.Print("Channel.HandleRplTopicWhoTime: while setting TopicSetBy: caught exception\n{0}", e);
            }

            try {
                TopicSetAt = UnixTimestampConverter.FromStringSeconds(ev.Message.Args[2]);
                Debug.Print("Channel.HandleRplTopicWhoTime: topic set at {0}", _topicSetAt.ToString("s"));
            }
            catch (Exception e) {
                Debug.Print("Channel.HandleRplTopicWhoTime: while setting TopicSetAt: caught exception\n{0}", e);
            }
        }
Example #3
0
 public void Convert(double timestamp, DateTime expectedDateTime)
 {
     Assert.Equal(expectedDateTime, UnixTimestampConverter.ToDateTime(timestamp));
     Assert.Equal(timestamp, UnixTimestampConverter.FromDateTime(UnixTimestampConverter.ToDateTime(timestamp)), 3);
 }
Example #4
0
        public void TestToDateTime()
        {
            DateTime resultDateTime = UnixTimestampConverter.ToDateTime(1585283580);

            Assert.AreEqual(new DateTime(2020, 3, 27, 4, 33, 0), resultDateTime);
        }
Example #5
0
        public void TestToUnixTimestamp()
        {
            double timestamp = UnixTimestampConverter.ToUnixtimestamp(new DateTime(2020, 3, 27, 4, 33, 0));

            Assert.AreEqual(1585283580, timestamp);
        }