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$
2
  • 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, 2015 at 15:35
  • $\begingroup$ @Searke, this is a nice tip. I have never used DateValue. $\endgroup$
    – Murta
    Aug 12, 2015 at 15:54

1 Answer 1

1
$\begingroup$

something like

   With[{DatePlus = Function[Null, Take[DatePlus[##], 3]]},
           stuff;
           DatePlus[2]
   ]
$\endgroup$
1
  • $\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, 2015 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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