Last active
September 15, 2016 01:44
-
-
Save wadackel/a7eaebe20fe61294126eb7e15e9548dd to your computer and use it in GitHub Desktop.
Convert absolute time from relative time in GitHub, for Chrome. (Example: 15 minutes ago -> 2016-09-15 10:06:20)
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
| // Original | |
| (() => { | |
| "use strict"; | |
| const el = document.querySelectorAll("time-ago,relative-time") || []; | |
| const pad = s => `0${s}`.slice(-2); | |
| Array.prototype.forEach.call(el, o => { | |
| const d = new Date(o.getAttribute("datetime")); | |
| o.textContent = [ | |
| `${d.getFullYear()}-`, `${pad(d.getMonth() + 1)}-`, `${pad(d.getDate())} `, | |
| `${pad(d.getHours())}:`, `${pad(d.getMinutes())}:`, `${pad(d.getSeconds())}` | |
| ].join(""); | |
| }); | |
| })(); | |
| // Bookmarklet | |
| // javascript: (()=>{"use strict";const el=document.querySelectorAll("time-ago,relative-time")||[];const pad=s=>`0${s}`.slice(-2);Array.prototype.forEach.call(el,o=>{const d=new Date(o.getAttribute("datetime"));o.textContent=[`${d.getFullYear()}-`,`${pad(d.getMonth()+1)}-`,`${pad(d.getDate())} `,`${pad(d.getHours())}:`,`${pad(d.getMinutes())}:`,`${pad(d.getSeconds())}`].join("");});})();void 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment