Mycroft Community Forum

How to pass utterance to extract_datetime

Hi there.

After looking at the examples on github and on readthedocs, I can see that extract_datetime() is expecting a string argument. I tried str(message) and then normalize(message), but both returned TypeError: expected string or bytes-like object.

The method works if I provide a string argument directly in the code. But I don’t see how to pass the utterance as a string.

  1. Is there a way to cast a message object as a string?
  2. Can somebody show me where the documentation is about message objects?

Thank you so much!

message is an object of the Message class.

if you want to pass the utterance

dt, rest = extract_datetime("utterance", ""),  now_local())  # anchorDate=now_local()

btw. messages with intents structured like some {superb} intent (padatious) or .require("superb") - or variations thereof - (adapt) will carry[“superb”]. (while the whole utterance still on data) Just FYI.


Just to add - the now_local() you have as the reference datetime is added automatically by mycroft-core. Eg by default we assume the frame of reference for what was said is the current time in the devices configured location.

So if I said:

“they want to catch up tomorrow in Paris”

that would be tomorrow in the context of me being in Australia and the time being 2:25pm on the 2nd of December (which the device already knows). So I can just use:


If the utterance related to a different timezone, or a different point in time, you can pass in a different “anchor time”. Eg:

“they want to catch up tomorrow in Paris”

We might then want to pass in the current datetime with a Paris timezone.

extract_datetime("utterance"), now_in_paris)
1 Like

Awesome. Thank you for the replies. These are both very helpful.