Author Topic: Manipulating {time}  (Read 14070 times)

Tinman_au

  • Newbie
  • *
  • Posts: 10
Manipulating {time}
« on: May 14, 2016, 11:49:29 PM »
There anyway I can get set a variable using the {time} token and subtract X hours off it to create a variable I can then get the TTS engine to say the time in UTC/GMT?

ED uses UTC for it's in game time, so this would be vary handy to track the timed multipart missions they have now.

PS: Nice forums Gary :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: Manipulating {time}
« Reply #1 on: May 15, 2016, 10:21:14 AM »
You can simply use the {EXP:} token directly in the "Say Something with Text-To-Speech" field:
Code: [Select]
Current UTC time is {EXP:{TIMEHOUR}-5} {TIMEMINUTE}

Rhaedas

  • Jr. Member
  • **
  • Posts: 72
Re: Manipulating {time}
« Reply #2 on: May 15, 2016, 12:40:46 PM »
Nice, think I might change my time prompt. Only...it won't know if it's stupid daylight savings time or not, so I'd have to adjust the number.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: Manipulating {time}
« Reply #3 on: May 15, 2016, 01:59:14 PM »
Ah, of course. I made a feature request for this.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
Re: Manipulating {time}
« Reply #4 on: May 15, 2016, 10:04:55 PM »
I'll add this to the todo list. 

Just a note...  Going all the way back to 2010, Tinman was one of the first to buy a VoiceAttack key.  Thanks, bud ;)

Tinman_au

  • Newbie
  • *
  • Posts: 10
Re: Manipulating {time}
« Reply #5 on: May 16, 2016, 05:35:54 PM »
And one of the most used things I've ever bought on the internet too!

Really happy to see your doing so well   :)

Tinman_au

  • Newbie
  • *
  • Posts: 10
Re: Manipulating {time}
« Reply #6 on: May 16, 2016, 05:41:22 PM »
You can simply use the {EXP:} token directly in the "Say Something with Text-To-Speech" field:
Code: [Select]
Current UTC time is {EXP:{TIMEHOUR}-5} {TIMEMINUTE}

Cheers Pfeil, I'll give it a try when I get home.

Tinman_au

  • Newbie
  • *
  • Posts: 10
Re: Manipulating {time}
« Reply #7 on: May 18, 2016, 06:12:52 AM »
Worked fine, thanks Pfeil.

I was trying to do the same thing with the {time} token, but I guess thats a text string (considering it has AM/PM on the end)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: Manipulating {time}
« Reply #8 on: May 18, 2016, 11:51:44 AM »
I was trying to do the same thing with the {time} token, but I guess thats a text string (considering it has AM/PM on the end)
I can't say what its internal type would be, but trying to manipulate it as an integer cannot work.

If you're not doing it inline you could actually use the relatively new "Set a Date/Time Value" to add hours. Though I don't see the benefit to that in this context.


If you'd like to have an "AM/PM" designation, adding "{TIMEAMPM}" to the end should work:
Code: [Select]
Current UTC time is {EXP:{TIMEHOUR}-5} {TIMEMINUTE} {TIMEAMPM}
« Last Edit: May 18, 2016, 12:03:28 PM by Pfeil »

Tinman_au

  • Newbie
  • *
  • Posts: 10
Re: Manipulating {time}
« Reply #9 on: May 18, 2016, 09:19:28 PM »
Actually, I have run into one wrinkle, VA TTS says it's "minus nine" when it's 3:00 AM UTC (using -10 for my TZ).  Seems to work fine in the PM though

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: Manipulating {time}
« Reply #10 on: May 19, 2016, 10:46:05 AM »
Actually, I have run into one wrinkle, VA TTS says it's "minus nine" when it's 3:00 AM UTC (using -10 for my TZ).  Seems to work fine in the PM though
Derp. Of course it would. Obviously my method was too simplistic, apologies. I'm terrible with math/numbers, to be honest.


You can try this(also included to import):
Code: [Select]
Set small int (condition) [TIMEUTC] value to the converted value of {TIMEHOUR}
Set small int (condition) [TIMEUTC] value as decremented by 10
Begin Small Integer Compare : [TIMEUTC] Is Less Than Or Equals 0
    Set small int (condition) [TIMEUTC] value to the converted value of {EXP:12+{SMALL:TIMEUTC}}
End Condition
Say, 'Current UTC time is {SMALL:TIMEUTC} {TIMEMINUTE} {TIMEAMPM}'


There is a relatively undocumented way to use the "date" datatype with a token. When the next VoiceAttack update allows subtraction, you could use:
Code: [Select]
Set date [TIMEUTC] value to [Not Set]
Set date [TIMEUTC] to [TIMEUTC] plus -10 hours
Say, 'Current UTC time is {TIMEHOUR:TIMEUTC} {TIMEMINUTE} {TIMEAMPM}'
Which is probably more reliable.
« Last Edit: May 19, 2016, 03:40:20 PM by Pfeil »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: Manipulating {time}
« Reply #11 on: May 19, 2016, 03:40:43 PM »
I spent quite a bit of time experimenting with "{EXP:}", which I definitely have a better understanding of now(and a mild headache, but no pain without gain, as they say).

The following should get you UTC for your timezone, in a single line:
Code: [Select]
Say, 'Current UTC time is {EXP: IIF( ({TIMEHOUR} - 10) <= 0,12+({TIMEHOUR} - 10),{TIMEHOUR} - 10)} {TIMEMINUTE} {TIMEAMPM}'

EDIT: Aha! There is a catch, of course there is! AM/PM would be not be adjusted for UTC, therefore the line must be:
Code: [Select]
Current UTC time is {EXP: IIF( ({TIMEHOUR} - 10) <= 0,12+({TIMEHOUR} - 10),{TIMEHOUR} - 10)} {TIMEMINUTE} {EXP: IIF( ({TIMEHOUR24} - 10) < 12,'A. M','P. M')}Note "A. M" and "P. M", which will correct the pronunciation(with Microsoft Anna at least).

Now I'm going back to bed. When something like this pops into my head, I know I can't sleep until I work it out.
« Last Edit: May 19, 2016, 09:43:28 PM by Pfeil »

Tinman_au

  • Newbie
  • *
  • Posts: 10
Re: Manipulating {time}
« Reply #12 on: May 22, 2016, 09:27:43 PM »
Cheers mate, thanks for the tenacity :o)