5
$\begingroup$

Now in V10.2, DatePlus has changed it behaviour in a undocumented way.

Now, DatePlus[n] (with n as Integer) return current date in the format:

{year, month, day, hour, minute, second}

Instead of:

{year, month, day}.

There is some parameter that controls that? So I can return to old behaviour?

IMHO this is a very bad practice. Make version update much more hard, and can easy break old code.

$\endgroup$
  • 13
    $\begingroup$ The best practice is to always use DateValue when working with Dates. This decouples your code from the way that these date functions will choose to represent their output. $\endgroup$ – Searke Aug 12 '15 at 15:35
  • $\begingroup$ @Searke, this is a nice tip. I have never used DateValue. $\endgroup$ – Murta Aug 12 '15 at 15:54
1
$\begingroup$

something like

   With[{DatePlus = Function[Null, Take[DatePlus[##], 3]]},
           stuff;
           DatePlus[2]
   ]
$\endgroup$
  • $\begingroup$ Why not With[{DatePlus = Take[DatePlus[##], 3] &}, (* stuff *) DatePlus[2]] or even With[{DatePlus = DatePlus[##][[;; 3]] &}, (* stuff *) DatePlus[2]]? $\endgroup$ – m_goldberg Aug 17 '15 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.