Skip to content

Instantly share code, notes, and snippets.

@fitnr
Created September 18, 2012 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fitnr/3745085 to your computer and use it in GitHub Desktop.
Save fitnr/3745085 to your computer and use it in GitHub Desktop.
Insert date and time in Sublime Text 2
import sublime_plugin
import time
class InsertDateTimeCommand(sublime_plugin.TextCommand):
def run(self, edit, **args):
sel = self.view.sel()
output = self.date(args)
for s in sel:
self.view.replace(edit, s, output)
def date(self, args):
try:
return time.strftime(args['format'])
except:
return time.ctime()
[
{ "caption": "Insert Date", "command": "insert_date_time", "args": {"format": "%B %d, %Y" }},
{ "caption": "Insert Time", "command": "insert_date_time", "args": {"format": "%I:%M %p" }},
{ "caption": "Insert Date and Time", "command": "insert_date_time", "args": {"format": "%B %d, %Y %I:%M %p" }}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment