Created
September 18, 2012 18:59
-
-
Save fitnr/3745085 to your computer and use it in GitHub Desktop.
Insert date and time in Sublime Text 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
[ | |
{ "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