Query content issue, bad.

Post your questions and help other users.

Moderator: Martin

Post Reply
evebrea
Posts: 116
Joined: 12 Aug 2013 15:28

Query content issue, bad.

Post by evebrea » 24 Mar 2017 16:19

I'm using this

content://com.android.calendar/instances/when/{triggertime}/{addHours(triggertime,8)}

to try to check from now, to 8 hours + and several things happen. projection :title sometimes does not get the title i'm looking for. that is when i next do expression : event_title == "Work" it returns false, when i do have a calendar event named "Work" within 8 hours.

Next, when it DOES work and it tries to next get the start and end times using query content, it's getting TWO numbers each time which then screws up the conversion of seconds(milliseconds?) to something speakable using someone else's modified "determine time and set talk text" ,wherein it tries to do math to convert it to 12H time format... it cannot do this because it is trying to do it on "1490400000000 1490376600000" rather than a single number

evebrea
Posts: 116
Joined: 12 Aug 2013 15:28

Re: Query content issue, bad.

Post by evebrea » 24 Mar 2017 16:23

This is the modified bit, script "determine time and set talk text"

just to say the starting time of "Work" , there's a second one for "endtime", but the whole thing goes back to query content getting TWO numbers that breaks this.

// Get hours and minutes
// Use 24h format to cater for midnight



hrs = "{starttime, dateformat, k}";
m = "{starttime, dateformat, m}";

sun = "{starttime, dateformat, a}";
h = hrs;

// Convert back to 12 hour format
if (h > 12)
{h = h-12;}


// Logic to set speech text
if (hrs == 24 AND m == 0)
   {t = "midnight";}
else if (h == 12 AND m == 0)
   {t = "noon";}
else if (m == 0)
  {t = "{h} o'clock";}
else if (m == 1)
  {t = "{h} oh one";}
else if (m < 10)
  {t = "{h} oh {m}";}
else if (m < 30 AND m != 15)
   {t = "{h} {m}";}
else if (m == 15)
   {t = "{h} fifteen";}
else if (m == 30)
   {t = "{h} thirtee ";}

// Reset 12:00 to 0 hours
if (h == 12)
{h = 0;}

if (m == 59)
  {t = "{h} {m}";}
else if (m > 30 AND m != 45)
   {t = "{h} {m}";}
else if (m == 45)
   {t = "{h} forty-five";}


starttalktext = t + sun;

evebrea
Posts: 116
Joined: 12 Aug 2013 15:28

Re: Query content issue, bad.

Post by evebrea » 24 Mar 2017 16:27

Considering work today is at 1:30 pm it looks like the second number, "1490376600000" might be the one i'm after? I'm not sure Why i'm getting two numbers.

User avatar
Scotty
Posts: 78
Joined: 26 Aug 2016 20:29
Location: Southern California

Re: Query content issue, bad.

Post by Scotty » 24 Mar 2017 20:43

With regard to the relatively lengthy code to extract hours minutes, AM / PM value, etc., then speak the time, there's a simpler way to do it (although the spoken text doesn't say "o'clock", it says, for example, "Five PM" or "Five Oh Three PM").

The example below will change the large number (which is milliseconds since epoch) to the variable SinceEpoch, with the value in hours and minutes (am / pm). In this case, the value is 05:01PM

Action / Script

SinceEpoch = "{1490400060000, dateformat, hh:mma}";

Follow that with Action / Speech Output, and in the Text, enter {SinceEpoch}

Run it, and it should say Five Oh One PM. Note that - even though the hour value is actually two-digit (05) - the speech output parses it correctly (it doesn't say Oh Five, it says Five).

evebrea
Posts: 116
Joined: 12 Aug 2013 15:28

Re: Query content issue, bad.

Post by evebrea » 24 Mar 2017 20:50

but it doesn't fix the whole issue of query content getting 2 numbers

User avatar
Scotty
Posts: 78
Joined: 26 Aug 2016 20:29
Location: Southern California

Re: Query content issue, bad.

Post by Scotty » 24 Mar 2017 20:57

evebrea wrote:but it doesn't fix the whole issue of query content getting 2 numbers
I'm aware of that; as I wrote in my post, I was providing a simpler alternative to your lengthy code in your 2nd post. I'm not actually sure why you posted that code, because it doesn't seem directly relevant to your problem (which is having 2 numbers).

Maybe upload the flow, and see if anyone can help with that?

Good luck !

Scotty

evebrea
Posts: 116
Joined: 12 Aug 2013 15:28

Re: Query content issue, bad.

Post by evebrea » 25 Mar 2017 00:13

Sorry, i was at work for that. Thanks for the bit to make a shorter "time speak", but with query content still returning two numbers, it would get just as confused as what i'm using right now. So i need to know why query content is getting two different numbers XD

Post Reply