Sirush / UDHBot

MIT License
0 stars 0 forks source link

Fixed natural duration mute #94

Closed Pierre-Demessence closed 5 years ago

Pierre-Demessence commented 5 years ago

Since time pass as the line is processed, DateTime.Now has a new value when we do the difference. And since .TotalSeconds returns a Decimal value, when casting it to a uint we get only the integer part which lack the few ms difference.

By rounding it we can avoid this small difference.

Pierre-Demessence commented 5 years ago

Example: If we enter "1 minutes" when DateTime.Now is exactly 00:00:00 (hh:mm:ss) DateTime dt = DateTime.Now.Offset("1 minutes"); will create a DateTime of 00:01:00.

But when going to the next line, DateTime.now is now a bit ahead, let's say 00:00:00.002. (We assume it took 0.02s to process the previous line). The difference between 00:01:00 and 00:00:00.02 is then 59.98s which casted into a int makes 59s.