Skip to content

Instantly share code, notes, and snippets.

@ino46
Created January 20, 2009 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ino46/49548 to your computer and use it in GitHub Desktop.
Save ino46/49548 to your computer and use it in GitHub Desktop.
Ctrl + ; で現在時刻(ISO 8601 形式)を挿入
; name now_time.ahk
; description Ctrl + ; で現在時刻(ISO 8601 形式)を挿入
; auther ino46
; website http://d.hatena.ne.jp/ino46/
; version 0.0.3.1 (2009-01-21T01:34:42+09:00)
; defaulticon
; copyright
;
; special thanks to
; http://d.hatena.ne.jp/annin102/20080206/1202303113
^;:: ;Ctrl + セミコロン(;) が押された
FormatTime, TimeString, R , yyyy'-'MM'-'dd'T'HH':'mm':'ss ;yyyy-MM-ddTHH:mm:ss という形式で現在時刻を取得し、変数 TimeString へ代入
getTimeZone = %A_Now% ;ローカル時刻(組み込み変数 A_Now)を取得し、変数 getTimeZone へ代入
EnvSub, getTimeZone, %A_NowUTC%, Hours ;ローカル時刻から 協定世界時(組み込み変数 A_NowUTC)を引いた値(単位は時)を取得し、変数 getTimeZone へ代入
TimeZoneConverter(x) {
if (x==0) { ;引数 x(変数 getTimeZone) の値が 0 である場合
x = +00:00 ;x に +00:00 を代入
return x ;x を返す
}else if (x>0) { ;x の値が 0 より大きい場合
x:=Abs(x) ;x の値を絶対値に
if (x>9) { ;x の値が二桁の場合
x = +%x%:00 ;x に +x:00 を代入
return x ;x を返す
}else{ ;x の値が一桁の場合
x = +0%x%:00 ;x に +0x:00 を代入
return x ;x を返す
}
}else{ ;x の値が 0 より小さい場合
x:=Abs(x) ;x の値を絶対値に
if (x>9) { ;x の値が二桁の場合
x = -%x%:00 ;x に -x:00 を代入
return x ;x を返す
}else{ ;x の値が一桁の場合
x = -0%x%:00 ;x に -0x:00 を代入
return x ;x を返す
}
}
}
TimeZone := TimeZoneConverter(getTimeZone) ;関数 TimeZoneConverter (引数に変数 getTimeZone)の結果を変数 TimeZone へ代入
clipboard = ;クリップボードを空にする
clipboard = %TimeString%%TimeZone% ;変数 TimeString と変数 TimeZone を連結しクリップボードへ挿入
Send, +{INSERT} ;INSERT 実行
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment