Home  >  Article  >  Backend Development  >  The difference between Minutes and TotalMinutes in C#

The difference between Minutes and TotalMinutes in C#

黄舟
黄舟Original
2017-09-16 11:07:045050browse

A bug was mentioned in today's test, saying that the timing of the message reminder was wrong. It was set 2 hours in advance, and the reminder was issued before it arrived.

Looked at the code


(m.ExpectReceiveTime - DateTime.Now).Minutes < (pModel.ErtDelayPrevMinutes == -999 ? 0 : pModel.ErtDelayPrevMinutes))

Executed


##

(m.ExpectReceiveTime - DateTime.Now).Minutes

The result is 55, logically it should It is 170

Execution


(m.ExpectReceiveTime - DateTime.Now).TotalMinutes

The result is 169.89568451

Finally modify the code to


(Convert.ToDecimal((m.ExpectReceiveTime - DateTime.Now).TotalMinutes) < (pModel.ErtDelayPrevMinutes == -999 ? 0 : pModel.ErtDelayPrevMinutes))

BUG SOLVED

Supplement:

Days;              //天部分 Hours; //小时部分
Milliseconds;      //毫秒部分
Minutes;           //分部分
Seconds;           //秒部分
Ticks;             //Tick 总数
TotalDays;         //总天数
TotalHours;        //总小时数
TotalMilliseconds; //总毫秒数
TotalMinutes;      //总分钟数
TotalSeconds;      //总秒数

The above is the detailed content of The difference between Minutes and TotalMinutes in C#. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn