自己开发的 Sublime 2/3 时间戳插件,时间的相互转换

2015-06-05 17:56:54 +08:00
 wizarot
数据库用时间戳记录的.有时候查询到的数据,需要转换过来,每次都写东西,或者去网站挺麻烦的,就写了个简单东西.
https://github.com/wizarot/sublime_timestamp

key + tab

key format example
now Y-m-d H:i:s 2014-11-22 14:41:54
tsnow timestamp 140xxxxxxx
2014-12-22-05-5-23 timestamp 140xxxxxxx

安装好后,输入 now+tab键, 就转换为当前时间
tsnow+tab键,转换为当前时间戳
时间戳+tab键,转换为时间戳对应时间
2014-12-22-05-5-23+tab键,转换为年月日对应的时间戳.方便写select语句的时间戳条件

希望有人能喜欢.

https://github.com/wizarot/sublime_timestamp
2984 次点击
所在节点    分享创造
1 条回复
jiehuangwei
2015-06-23 18:58:37 +08:00
简单的 时间戳 转换插件
import sublime, sublime_plugin
import time

class TestCommand(sublime_plugin.TextCommand):
def run(self, edit):
# 1430539200
# 1430539200
for sel in self.view.sel():
t = float(self.view.substr(sel))
try:
self.view.replace(edit, sel, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t)))
except:
pass

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/196374

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX