Skip to content

Instantly share code, notes, and snippets.

@4mcn
Last active December 17, 2015 00:39
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4mcn/5522220 to your computer and use it in GitHub Desktop.
Save 4mcn/5522220 to your computer and use it in GitHub Desktop.
ツイートの投稿時刻をミリ秒単位まで表示できるようにするmikutterプラグイン
# -*- 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