What is the difference between Minutes and TotalMinutes?
A bug was raised during the test today, saying that the message reminder time is incorrect. The setting is two hours ahead of schedule, and the notification is sent before it arrives.
Read the code
(m.ExpectReceiveTime - DateTime.Now).Minutes < (pModel.ErtDelayPrevMinutes == -999 ? 0 : pModel.ErtDelayPrevMinutes))
Run
(m.ExpectReceiveTime - DateTime.Now).Minutes
The result is 55, which is 170.
Run
(m.ExpectReceiveTime - DateTime.Now).TotalMinutes
Result 169.89568451
Finally, change the code
(Convert.ToDecimal((m.ExpectReceiveTime - DateTime.Now).TotalMinutes) < (pModel.ErtDelayPrevMinutes == -999 ? 0 : pModel.ErtDelayPrevMinutes))
BUG solving
Summary:
1. Minutes calculation is limited to Minutes, Int type, (-59 to 59)
Https://msdn.microsoft.com/zh-cn/library/vs/alm/system.timespan.minutes/css
2. TotalMinutes is calculated as the number of minutes of the entire time, double type.
Https://msdn.microsoft.com/zh-cn/library/vs/alm/system.timespan.totalminutes/css
Supplement:
Days; // Day Part Hours; // Hour Part
Milliseconds; // millisecond part
Minutes; // parts
Seconds; // Seconds
Ticks; // total number of Tick
TotalDays; // Total Number of days
TotalHours; // total hours
TotalMilliseconds; // The total number of milliseconds
TotalMinutes; // The total number of minutes
TotalSeconds; // The total number of seconds.