[GH-ISSUE #532] [Enhancement Request] Use of Macros for date #350

Open
opened 2026-03-03 01:11:54 +03:00 by kerem · 2 comments
Owner

Originally created by @ffrager on GitHub (Aug 29, 2023).
Original GitHub issue: https://github.com/Clipy/Clipy/issues/532

It would be super useful to add some sort of macro for Snippets with the date, something like currentDate() will paste the system or browser today's date

Originally created by @ffrager on GitHub (Aug 29, 2023). Original GitHub issue: https://github.com/Clipy/Clipy/issues/532 It would be super useful to add some sort of macro for Snippets with the date, something like currentDate() will paste the system or browser today's date
Author
Owner

@thompson-jj commented on GitHub (Sep 25, 2023):

I support this request - it would be great to have this feature, as someone that enters the date on files multiple times a day in various applications, this feature would be amazing! and the ability to change the format (YYYYMMDD or DD-MM-YYYY)

<!-- gh-comment-id:1734595171 --> @thompson-jj commented on GitHub (Sep 25, 2023): I support this request - it would be great to have this feature, as someone that enters the date on files multiple times a day in various applications, this feature would be amazing! and the ability to change the format (YYYYMMDD or DD-MM-YYYY)
Author
Owner

@ysaereve commented on GitHub (Oct 3, 2024):

Thanks for creating this wonderful tool Clipy. 👍 +1, +n for this [Enhancement Request]. ✌️

At this monument, I use the following as a temporary solution (not good enough):
Inserting Date & Time on Mac OS
https://explog.in/notes/inserttimestamp.html

Apple script is not allowed to send keyst… - Apple Community
https://discussions.apple.com/thread/255165673?sortBy=rank

AppleScript to get current date and time (YYYY-MM-DD HH:MM:SS). Usable as a Text Service in Mac OS X.
https://gist.github.com/Glutexo/78c170e2e314f0eacc1a

Note:

  1. For some reason, after making the changes in "System Settings", I have to restart my system to make it work.
  2. Updated version, so a) it can utilize clipboard & Clipy. b) it does not need Automation "System Events" permission.
  3. Updated version, if only use AppleScript. (I like the shell script one better.)
on run {input, parameters}
	set dateString to do shell script "date +'%Y-%m-%d %H:%M:%S'"
	set the clipboard to dateString
	-- tell application "System Events"
	--	keystroke dateString
	-- end tell
	return input
end run
(*
	The zero_pad function taken from:
	http://www.nineboxes.net/2009/10/an-applescript-function-to-zero-pad-integers/
*)
on zero_pad(value, string_length)
	set string_zeroes to ""
	set digits_to_pad to string_length - (length of (value as string))
	if digits_to_pad > 0 then
		repeat digits_to_pad times
			set string_zeroes to string_zeroes & "0" as string
		end repeat
	end if
	set padded_value to string_zeroes & value as string
	return padded_value
end zero_pad

(*
	Base on:
	AppleScript to get current date and time (YYYY-MM-DD HH:MM:SS). Usable as a Text Service in Mac OS X.
	https://gist.github.com/Glutexo/78c170e2e314f0eacc1a
*)
on run {input, parameters}
	set now to (current date)
	
	set yyyy to (year of now as integer) as string
	set mm to zero_pad(month of now as integer, 2)
	set dd to zero_pad(day of now as integer, 2)
	set HH to zero_pad(hours of now as integer, 2)
	set NN to zero_pad(minutes of now as integer, 2)
	set SS to zero_pad(seconds of now as integer, 2)
	set the clipboard to yyyy & "-" & mm & "-" & dd & " " & HH & ":" & NN & ":" & SS
	
	return input
end run
<!-- gh-comment-id:2390457548 --> @ysaereve commented on GitHub (Oct 3, 2024): Thanks for creating this wonderful tool Clipy. 👍 +1, +n for this [Enhancement Request]. ✌️ At this monument, I use the following as a temporary solution (not good enough): Inserting Date & Time on Mac OS https://explog.in/notes/inserttimestamp.html Apple script is not allowed to send keyst… - Apple Community https://discussions.apple.com/thread/255165673?sortBy=rank AppleScript to get current date and time (YYYY-MM-DD HH:MM:SS). Usable as a Text Service in Mac OS X. https://gist.github.com/Glutexo/78c170e2e314f0eacc1a Note: 1. For some reason, after making the changes in "System Settings", I have to restart my system to make it work. 2. Updated version, so a) it can utilize clipboard & Clipy. b) it does not need Automation "System Events" permission. 3. Updated version, if only use AppleScript. (I like the shell script one better.) ``` on run {input, parameters} set dateString to do shell script "date +'%Y-%m-%d %H:%M:%S'" set the clipboard to dateString -- tell application "System Events" -- keystroke dateString -- end tell return input end run ``` ``` (* The zero_pad function taken from: http://www.nineboxes.net/2009/10/an-applescript-function-to-zero-pad-integers/ *) on zero_pad(value, string_length) set string_zeroes to "" set digits_to_pad to string_length - (length of (value as string)) if digits_to_pad > 0 then repeat digits_to_pad times set string_zeroes to string_zeroes & "0" as string end repeat end if set padded_value to string_zeroes & value as string return padded_value end zero_pad (* Base on: AppleScript to get current date and time (YYYY-MM-DD HH:MM:SS). Usable as a Text Service in Mac OS X. https://gist.github.com/Glutexo/78c170e2e314f0eacc1a *) on run {input, parameters} set now to (current date) set yyyy to (year of now as integer) as string set mm to zero_pad(month of now as integer, 2) set dd to zero_pad(day of now as integer, 2) set HH to zero_pad(hours of now as integer, 2) set NN to zero_pad(minutes of now as integer, 2) set SS to zero_pad(seconds of now as integer, 2) set the clipboard to yyyy & "-" & mm & "-" & dd & " " & HH & ":" & NN & ":" & SS return input end run ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Clipy#350
No description provided.