Author Topic: {DATETIMEFORMAT:formatVariable} token not working for 'YY' and 'DD'  (Read 4371 times)

ymangolds

  • Newbie
  • *
  • Posts: 3
When I try generating a 'minute stamp' using the below:
Code: [Select]
Set text [runNumDateFormat] to 'YY-MM-DD-HH-mm'
Set text [runNum] to '{DATETIMEFORMAT:runNumDateFormat}' (save value to profile)
Execute command, 'Get Recognition Profile Info' (and wait until it completes)
Set text [runPath] to '{VA_SOUNDS}\{TXT:~~WSRCurrentProfile}\{TXT:runNum}\' (save value to profile)
Inline C# Function: Create directories, wait until execution finishes
The {DATETIMEFORMAT:formatVariable} doesn't understand 'YY' (2 digit year) or 'DD' (zero padded day), so it results in something that looks like (actual output): "YY-09-DD-08-35"

I've come up with a work around by using other tokens and expressions:
Code: [Select]
Set text [~year] to {DATEYEAR}
Set text [runNum] to '{TXTSUBSTR:~year:2:2}-{EXP: IIF({DATEMONTHNUMERIC} < 10,0,'')}{DATEMONTHNUMERIC}-{EXP: IIF({DATEDAY} < 10,0,'')}{DATEDAY}-{TIMEHOUR24}-{EXP: IIF({TIMEMINUTE} < 10,0,'')}{TIMEMINUTE}' (save value to profile)
Execute command, 'Get Recognition Profile Info' (and wait until it completes)
Set text [runPath] to '{VA_SOUNDS}\{TXT:~~WSRCurrentProfile}\{TXT:runNum}\' (save value to profile)
Inline C# Function: Create directories, wait until execution finishes

Notes about the workaround:
{TIMEHOUR24} already zero pads the number (and is the only token I found that does).
{TXTSUBSTR:{DATEYEAR}:2:2} doesn't work and resolves to 'Not Set,' which is why I had to put the full year into '~year' first.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4767
  • RTFM
Re: {DATETIMEFORMAT:formatVariable} token not working for 'YY' and 'DD'
« Reply #1 on: September 23, 2022, 08:15:19 AM »
"YY" and "DD" are not valid custom format specifiers. Format specifiers are case-sensitive.

Valid specifiers are listed in this Microsoft article.


{TXTSUBSTR:{DATEYEAR}:2:2} doesn't work and resolves to 'Not Set,' which is why I had to put the full year into '~year' first.
You are passing a literal value (which is what a token resolves to) as a variable name. Therefore the "{TXTSUBSTR:}" token is retrieving the value of a variable named "2022", which unless you have assigned a value to it, would indeed be "Not set".

Press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer, which contains information on VoiceAttack's features.
The method for passing literal values to that token (which applies to several tokens) is shown.

ymangolds

  • Newbie
  • *
  • Posts: 3
Re: {DATETIMEFORMAT:formatVariable} token not working for 'YY' and 'DD'
« Reply #2 on: September 23, 2022, 11:59:35 AM »
Thank you! :D Got things working as I had originally hoped using 'yy-MM-dd-HH-mm'. You may want to include the link to the datetime format syntax in the docs (or list the options/syntax in the docs). My first custom format of 'YY-MM-DD-HH-mm' was based off of https://devhints.io/datetime.

I also got {TXTSUBSTR:{DATEYEAR}:2:2} to work correctly by changing it to {TXTSUBSTR:"{DATEYEAR}":2:2}. I've read the docs beginning-to-end multiple times, and the wording regarding tokens, literals, variables, and when and why to use double quotes is a bit difficult to follow. Maybe adding examples to the 'nested tokens' section that demonstrate that might make things easier to understand.

jEffie

  • Newbie
  • *
  • Posts: 3
Re: {DATETIMEFORMAT:formatVariable} token not working for 'YY' and 'DD'
« Reply #3 on: September 23, 2022, 12:40:53 PM »
The link shows Moment.js date time format.  The help doc shows as 'standard date format' and if you search for standard date format you will see the correct values.

ymangolds

  • Newbie
  • *
  • Posts: 3
Re: {DATETIMEFORMAT:formatVariable} token not working for 'YY' and 'DD'
« Reply #4 on: September 23, 2022, 03:44:40 PM »
Yes, I made a mistake  :-[ . I had assumed the formatting was standard syntax further down the page that I found when I searched for 'date format syntax.'

You can move this thread to resolved issues (or delete it since the only 'issue' was with me and the software works as intended :o ).

Thank you for helping me understand. ;D