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(); } }
// 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); } }
public void Convert(double timestamp, DateTime expectedDateTime) { Assert.Equal(expectedDateTime, UnixTimestampConverter.ToDateTime(timestamp)); Assert.Equal(timestamp, UnixTimestampConverter.FromDateTime(UnixTimestampConverter.ToDateTime(timestamp)), 3); }
public void TestToDateTime() { DateTime resultDateTime = UnixTimestampConverter.ToDateTime(1585283580); Assert.AreEqual(new DateTime(2020, 3, 27, 4, 33, 0), resultDateTime); }
public void TestToUnixTimestamp() { double timestamp = UnixTimestampConverter.ToUnixtimestamp(new DateTime(2020, 3, 27, 4, 33, 0)); Assert.AreEqual(1585283580, timestamp); }