Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
385 views
in Technique[技术] by (71.8m points)

How to convert date (YYYY-MM-DD) to today/tomorrow etc in Alexa custom skill?

I know about AMAZON.DATE Built-in Slot Types which can convert today/tomorrow to date in format YYYY-MM-DD. When a user speak today/tomorrow then alexa converts it to date but I want alexa to speak today/tomorrow based on the date. I have an object of string contains yyyy-mm-dd hh:mm I want alexa to speak date & time in the form defined in AMAZON.DATE. I seen Speech Synthesis Markup Language (SSML) but did not get any reference to convert date to such words like defined in AMAZON.DATE.

Thanks.

question from:https://stackoverflow.com/questions/65918922/how-to-convert-date-yyyy-mm-dd-to-today-tomorrow-etc-in-alexa-custom-skill

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

That conversion for output is something you do in your code. Any formatting of how the date is spoken on output is up to your code to do. If you're using JavaScript, the moment library can be useful. If you want to keep your code tight and memory usage low, read up on the Date object.

For a little help in doing it correctly, check out the last section of the beginner Cake Time tutorial, which explains how to get the time zone of the device, so your date math is accurate.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...