Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# -*- coding: utf-8 -*-
from datetime import datetime
import sublime_plugin
class TimestampCommand(sublime_plugin.EventListener):
"""Expand `isoD`, `now`, `datetime`, `utcnow`, `utcdatetime`,
`date` and `time`
def on_query_completions(self, view, prefix, locations):
if prefix in ('isoD', 'now', 'datetime'):
val ='%Y-%m-%dT%H:%M:%S')
elif prefix in ('utcnow', 'utcdatetime'):
val = datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S')
elif prefix == 'date':
val ='%Y-%m-%d')
elif prefix == 'time':
val ='%H:%M:%S')
val = None
return [(prefix, prefix, val)] if val else []

This comment has been minimized.

Copy link

commented Jun 28, 2013

Gists have no pull requests. I when I updated the gist, I stuck it a repo merriam/timestamp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.