2 parts needed: a Python module to generate the string, and a definition to make the class available as a Sublime Text command.
The end result of all of this is a new Sublime Text command which outputs something like this at the current cursor position:
2019-05-01T19:53+1000
~/Library/Application Support/Sublime Text 3/Packages/User/date-time-stamp.py
Python module which defines a subclass of sublime_plugin.TextCommand
and uses Sublime Text’s hooks to spew out a formatted datetime as a snippet.
Ever tried to get Python to output the local UTC offset? What a mess. My solution was shamelessly stolen from this Stack Overflow answer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
~/Library/Application Support/Sublime Text 3/Packages/User/date-time.sublime-commands
This surfaces the new class method in Sublime Text’s command pallet:
1 2 3 4 5 6 |
|