try to AddMinuts in DateTime

  • Thread starter Thread starter Elmar Jacobs
  • Start date Start date
E

Elmar Jacobs

hi guys,
i try in this way

c#
System.DateTime actDateTime = CDocument.instance().getDateTime();
lastWarningDateTime = actDateTime;
lastWarningDateTime.AddMinutes(6);

if (lastWarningDateTime == actDateTime)
actDateTime = actDateTime;
c#

to add an offset in an instance of DateTime class. It's not working. The
compare shows that botth instance have the same value after adding the
offset.

Do anybody knows what i do wrong?

thanks a lot,
elmar
 
AddMinutes() returns the new time. It doesn't change the time of the object.
This one got me early on as well.

so do:

lastWarningDateTime = lastWarningDateTime.AddMinutes(6);


Pete
 
Elmar,

You need to store the return value of the call to AddMinutes, as the
call doesn't modify the current DateTime instance.

Also, you might want to consider your naming conventions. You are
violating at least two recommendations for naming conventions (with the C in
front of the Document class, and the camel cased methods). You also should
expose instance and getDateTime as properties, not methods.

Hope this helps.
 
Back
Top