-
-
Save swrogers/d8b93f873b490034610d79c497024508 to your computer and use it in GitHub Desktop.
Revisions
-
takehiko created this gist
Feb 17, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ ;; M-x insert-timestamp-default (またはM-x its)で Wed Feb 17 22:18:46 2021 ;; M-x insert-timestamp-htmlcomment (またはM-x itsh)で <!-- 2021-02-17 22:18:52 +09:00 --> (と改行) ;; M-x insert-timestamp-unixtime (またはM-x itsu)で 1613567937 ;; M-x insert-timestamp-iso (またはM-x itsi)で 2021-02-17T22:19:01+09:00 (defun insert-timestamp-default () "Insert the current timestamp" (interactive) (insert (current-time-string))) (defalias 'its 'insert-timestamp-default) (defun insert-timestamp-htmlcomment () "Insert the current timestamp (HTML comment)" (interactive) (insert (concat "<!-- " (format-time-string "%Y-%m-%d %T ") ((lambda (x) (concat (substring x 0 3) ":" (substring x 3 5))) (format-time-string "%z")) " -->\n"))) (defalias 'itsh 'insert-timestamp-htmlcomment) (defun insert-timestamp-unixtime () "Insert the current Unix time" (interactive) (let ((time (current-time))) (let ((time1 (car time)) (time2 (car (cdr time)))) (insert (format "%d" (+ (* 65536 time1) time2)))))) (defalias 'itsu 'insert-timestamp-unixtime) (defun insert-timestamp-iso () "Insert the current timestamp (ISO 8601 format)" (interactive) (insert (concat (format-time-string "%Y-%m-%dT%T") ((lambda (x) (concat (substring x 0 3) ":" (substring x 3 5))) (format-time-string "%z"))))) (defalias 'itsi 'insert-timestamp-iso) (defalias 'itsiso 'insert-timestamp-iso)