digitalmars.D.learn - Can't understand how to compare DateTime with opCmp
- Suliman (9/9) Feb 01 2015 I need to compare to DateTime. I looked at docs and found opCmp
- Rene Zwanenburg (5/15) Feb 01 2015 opCmp is the operator overload for the comparison operators, so
- FG (3/8) Feb 01 2015 No. That would be `if (dtindb.opCmp(outoftime))`, but it's simpler to wr...
- Suliman (5/5) Feb 01 2015 Thanks! Could anybody say how can I use roll if I need to date to
- Suliman (1/1) Feb 01 2015 "+ n.days" solved my problem.
- Jonathan M Davis via Digitalmars-d-learn (8/9) Feb 01 2015 Roll is specifically for cases where you want one of the fields to incre...
I need to compare to DateTime. I looked at docs and found opCmp for DateTime type. The problem is that I can't understand how to use it. http://dlang.org/phobos/std_datetime.html#DateTime opCmp(in DateTime rhs); what is rhs? I am trying to do something like this: if( DateTime.opCmp(dtindb, outoftime)); But it's seems that I wrong understand how to use this function...
Feb 01 2015
On Sunday, 1 February 2015 at 15:04:39 UTC, Suliman wrote:I need to compare to DateTime. I looked at docs and found opCmp for DateTime type. The problem is that I can't understand how to use it. http://dlang.org/phobos/std_datetime.html#DateTime opCmp(in DateTime rhs); what is rhs? I am trying to do something like this: if( DateTime.opCmp(dtindb, outoftime)); But it's seems that I wrong understand how to use this function...opCmp is the operator overload for the comparison operators, so you can simple write: if(dtindb < outoftime) and it should work.
Feb 01 2015
On 2015-02-01 at 16:04, Suliman wrote:opCmp(in DateTime rhs); what is rhs?RHS is probably short of "right hand side", ie. the argument on the right side of the operator in a binary operator expression. In `a < b` it would be b.I am trying to do something like this: if( DateTime.opCmp(dtindb, outoftime)); But it's seems that I wrong understand how to use this function...No. That would be `if (dtindb.opCmp(outoftime))`, but it's simpler to write `if (dtindb < outoftime)`
Feb 01 2015
Thanks! Could anybody say how can I use roll if I need to date to date. For example I need to plus: DateTime currentdt = cast(DateTime)(Clock.currTime()); with another DateTime var foo.
Feb 01 2015
On Sunday, February 01, 2015 19:22:40 Suliman via Digitalmars-d-learn wrote:"+ n.days" solved my problem.Roll is specifically for cases where you want one of the fields to increase or decrease without affecting the others (e.g. if you had a spin control in your GUI with a DateTime backing it and didn't want any units other than the currently altered unit to change when its value wrapped around). In most cases, you're simply going to want to add a Duration to it - which dt + days(n) or dt + n.days will do. - Jonathan M Davis
Feb 01 2015