StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
delbres  
#1 Posted : Sunday, March 7, 2021 5:36:01 AM(UTC)
delbres

Rank: Newbie

Reputation:

Groups: Approved
Joined: 3/7/2021(UTC)
Posts: 2

i'm trying to insert the current date using a gesture, but i can't even begin to figure it out. can anyone help?


apologies if this was posted in the wrong section.
Rob  
#2 Posted : Sunday, March 7, 2021 6:40:09 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Here's a working example, change the formatting as needed.
Code:
var d = new Date();
//Build formatted date string, padding single digits with a preceding "0"
var dateString = d.getFullYear()
                 + "-"
                 + ("0" + (d.getMonth()+1)).slice(-2)
                 + "-"
                 + ("0" + d.getDate()).slice(-2)
                 + " "
                 + ("0" + d.getHours()).slice(-2) 
                 +  ":" 
                 + ("0" + d.getMinutes()).slice(-2);

//Send the date string as keyboard input
sp.SendString(dateString);
Rob  
#3 Posted : Sunday, March 7, 2021 6:48:20 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Actually, it's easier to use the .NET DateTime class instead:
Code:
sp.SendString(DateTime.Now.ToString("yyyy/MM/dd"));
sp.SendVKey(vk.RETURN);
sp.SendString(DateTime.Now.ToString("yyyy-MM-dd"));
sp.SendVKey(vk.RETURN);
sp.SendString(DateTime.Now.ToString("yy-MM-dd"));


See here for the formatting options:
https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

Edited by user Sunday, March 7, 2021 6:49:53 AM(UTC)  | Reason: Not specified

thanks 1 user thanked Rob for this useful post.
misaki4650 on 3/7/2021(UTC)
delbres  
#4 Posted : Sunday, March 7, 2021 7:15:10 AM(UTC)
delbres

Rank: Newbie

Reputation:

Groups: Approved
Joined: 3/7/2021(UTC)
Posts: 2

thanks for the help! greatly appreciated.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.