Last active
December 17, 2015 00:39
-
-
Save 4mcn/5522220 to your computer and use it in GitHub Desktop.
ツイートの投稿時刻をミリ秒単位まで表示できるようにするmikutterプラグイン
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
# -*- coding: utf-8 -*- | |
Plugin.create :timestamp_msec do | |
UserConfig[:show_msec] ||= true | |
settings '誰得機能' do | |
boolean '投稿時刻をミリ秒単位まで表示する', :show_msec | |
end | |
Gdk::MiraclePainter.__send__(:define_method, :timestamp_label) { | |
now = Time.now | |
is_today = message[:created].year == now.year && message[:created].month == now.month && message[:created].day == now.day | |
if UserConfig[:show_msec] and not message[:user][:id] == 0 | |
Pango.escape(Time.at(((message[:id]>>22)+1288834974657)/1000.0).strftime(is_today ? '%H:%M:%S.%L' : '%Y/%m/%d %H:%M:%S.%L')) | |
else | |
Pango.escape(message[:created].strftime(is_today ? '%H:%M:%S' : '%Y/%m/%d %H:%M:%S')) | |
end | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment