Help with estimated time of arrival!


#1

1) Give a description of the problem
Working on a commute notification.

2) What is the expected behaviour?
The expected behavior is to have Alexa speak the estimated time of arrival.

3) What is happening/not happening?
The format for the time - addMinutes - not in the right format.

My piston uses Google’s DistranceMatrix to find the # of minutes for my commute.
It stores this # in the variable “Traffic”.

I take this number, let’s say it is 50 minutes (Variable = Traffic), and I want to add that # of minutes to the current time.

With that arrival estimate time, I want Alexa to speak "I’ll be home at 5:50pm)

The problem is I can’t get the time to display: 5:50pm.

Instead, it shows the following:
5:00 P.M. Tue, Oct 1 2019 @ 5:50:55 PM EDT

So it is taking the current time (5:00pm) and then displaying what the date/time will be in 50 minutes.

My expression:
$time(addminutes(Traffic))

Thanks in advance!


#2

You’d probably be better off using formatDateTime() function.
https://wiki.webcore.co/Functions#formatDateTime

(expression) formatDateTime(1569946803,"h:mm a") »»» (string) 9:05 PM


#3

Thanks for the help.

That is kind of where I ended up in my testing, but I still get the same output:
(expression)
formatDateTime($time, “h:mm a”)(addMinutes(Traffic))

(output)
12:24 PMTue, Oct 1 2019 @ 12:44:09 PM EDT

I don’t know how to get the output of 12:44PM, w/o any of the other info…

I looked at that reference, but when I add "addMinutes ", the format is lost.


#4

Hmm, it should be…

formatDateTime(addMinutes($time,Traffic),"h:mm a")


#5

Thank you! I wouldn’t have guessed that =)
Working !!


#6

I just checked on this again in another test.
Traffic = Text variable of “20”
formatDateTime(addMinutes($time,Traffic),“h:mm a”)

It is returning an AM time, not a PM.

Do I need to add a time zone or something? It seems to be off by 12 hours.

This returns the correct time:
formatDateTime(addMinutes($time,721),“h:mm a”)

If I evaluate $time, the proper time is returned…


#7

What do you get if you enter this in the evaluation console?

formatDateTime($time,"h:mm a")


#8

I get the proper time, currently it is 9:41am:

formatDateTime($time,“h:mm a”)
Returns: (string) 9:41 AM


#9

I’m not sure what has changed… but if I re-run the piston manually, it now returns the correct/expected time.

formatDateTime(addMinutes($time, Traffic),“h:mm a”)
10:16am

It is currently 9:46, but TRAFFIC=30, so it looks good…