Skip to content

Instantly share code, notes, and snippets.

@lucaswilric
Forked from kmorey/timestamp.py
Last active August 29, 2015 14:12
Show Gist options
  • Save lucaswilric/042366c309111ca83182 to your computer and use it in GitHub Desktop.
Save lucaswilric/042366c309111ca83182 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from datetime import datetime
import time
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'):
val = datetime.now().strftime('%Y-%M-%dT%H:%M:%S')
elif prefix in ('now', 'datetime'):
val = datetime.now().strftime('%d %B %Y %H:%M:%S AEST')
elif prefix in ('utcnow', 'utcdatetime'):
val = datetime.utcnow().strftime('%d %B %Y %H:%M:%S UTC')
elif prefix == 'date':
val = datetime.now().strftime('%Y-%m-%d')
elif prefix == 'time':
val = datetime.now().strftime('%H:%M:%S')
else:
val = None
return [(prefix, prefix, val)] if val else []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment