duckling icon indicating copy to clipboard operation
duckling copied to clipboard

How to get day of week from "now" ?

Open taomanwai opened this issue 8 years ago • 2 comments

i know there is "now :: TimeData" defined to get the current time's TimeData

But how can I extract day of week (e.g. Monday, Tue, etc.) from it ? Inside TTime.timePred, right? But what should i do next ?

Thanks in advance

taomanwai avatar Jul 06 '18 05:07 taomanwai

It depends on what you're trying to do. If you're trying to get day of the week from a Time entity returned by Duckling you should be able to do it using the standard libraries (see: http://hackage.haskell.org/package/time-1.9.1/docs/Data-Time.html).

TTime also has a TTime.DayOfWeek. See https://github.com/facebook/duckling/blob/master/Duckling/Time/Helpers.hs for reference on how it's used.

If neither of those work for your use case, can you provide a bit more information about what you're trying to do?

adanielescu avatar Jul 10 '18 14:07 adanielescu

Hi, for example I have a calculator to convert current Year to current Lunar Year in calendar, will I be able to extract this current Year value from "now/today::Time Data" inside the Rule function ?

justinphan3110 avatar Jul 02 '19 07:07 justinphan3110