11
$\begingroup$

I used to use TimeObject in my code and pass it the string coming from a database system as follows and it used to convert it to the correct time.

TimeObject["3:28 PM","Minute"]

TimeObject[{15, 28}, "Minute"]

But now after updating to version 13. I get:

TimeObject["3:28 PM","Minute"]

TimeObject[{3, 28}, "Minute"]

What in the world is this? Is there a way to get the old functionality back? All my code is now messed up.


More screwups:

oldMonthFormat=AssociationThread[DateRange[DatePlus[CurrentDate["Month"],{-15,"Month"}],CurrentDate["Month"]]->RandomInteger[{0,100},16]];
newMonthFormat=AssociationThread[DateRange[DateObject[{2020,9}],DateObject[{2021,12}]]->RandomInteger[{0,100},16]];

Now let's try merging the totals by month:

Merge[{oldMonthFormat,newMonthFormat},Total]

doesn't Merge the months anymore. Everything about DateObject and TimeObject is screwed. This used to work in version 12.3.1.

What the hell did they do to Date and Time functions in version 13? Very disappointed with what I am seeing now.

  • Old Format: DateObject[{2021, 12}, "Month", "Gregorian", -5.]
  • New Format: DateObject[{2021, 12}, "Month"]
$\endgroup$
3
  • 3
    $\begingroup$ In v13: The FullForm of DateObject at certain granularities no longer explicitly includes default values for the calendar or time zone. Incompatible Changes $\endgroup$
    – Ben Izd
    Commented Dec 23, 2021 at 17:48
  • $\begingroup$ @BenIzd then why some functions are doing it and others are not? I am happy to make changes in my code but why is for example CurrentDate still on the older format then? $\endgroup$
    – user13892
    Commented Dec 23, 2021 at 17:54
  • 1
    $\begingroup$ @user13892 I'm also looking for an answer. Also for the first problem you can use this: TimeObject@ FromDateString["3:28 PM", {"Hour", ":", "Minute", " ", "AMPM"}, TimeZone -> 0] $\endgroup$
    – Ben Izd
    Commented Dec 23, 2021 at 17:58

1 Answer 1

7
$\begingroup$

If you experiment a bit, you'll find that it's just ignoring everything including and after the space. I have no idea if that's intended, but the behaviour you relied on does not appear to be documented.

The following works, if nothing else:

SemanticImportString["3:28pm", "Time"][[1]]
$\endgroup$
1
  • 1
    $\begingroup$ You could also add TextString@SemanticImportString["3:28pm", "Time"][[1]] to make it display 15:28 $\endgroup$
    – Nasser
    Commented Dec 23, 2021 at 17:16

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.