Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adrianorsouza/10549782 to your computer and use it in GitHub Desktop.
Save adrianorsouza/10549782 to your computer and use it in GitHub Desktop.
Create a Date Time Stamp in Sublime Text 2 on a Mac
import datetime, getpass
import sublime, sublime_plugin
class AddDateTimeStampCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet", { "contents": "%s" % datetime.datetime.now().strftime("%Y-%m-%d %H:%M") } ) #:%S") } )
class AddDateStampCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet", { "contents": "%s" % datetime.datetime.now().strftime("%Y-%m-%d") } )
class AddTimeStampCommand(sublime_plugin.TextCommand):
def run(self, edit):
self.view.run_command("insert_snippet", { "contents": "%s" % datetime.datetime.now().strftime("%H:%M:%S") } )
[
{"keys": ["alt+s"], "command": "add_date_time_stamp" },
{"keys": ["alt+d"], "command": "add_date_stamp" },
{"keys": ["alt+t"], "command": "add_time_stamp" }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment