generated at
scrapbox-timestamp
timestamp (scrapbox)を使用せずにtimestampを挿入するAPI
warning実際に使うにはPage MenuやScrapBindingsを併用してください

dependencies
script.js
import {insertText} from '/api/code/takker/scrapbox-insert-text/script.js'; import {toYYYYMMDD, toHHMMSS, toYYYYMMDD_HHMMSS} from '/api/code/takker/scrapbox-timestamp/timestamp.js';

タイムスタンプを作成する関数
timestamp.js
const zero = n => String(n).padStart(2, '0'); export function toYYYYMMDD(d, {separator = '-'} = {}) { return `${d.getFullYear()}${separator}${zero(d.getMonth() + 1)}${separator}${zero(d.getDate())}`; } export const toHHMMSS = d => `${zero(d.getHours())}:${zero(d.getMinutes())}:${zero(d.getSeconds())}`; export const toHHMM = d => `${zero(d.getHours())}:${zero(d.getMinutes())}`; export const toYYYYMMDD_HHMMSS = d => `${toYYYYMMDD(d)} ${toHHMMSS(d)}`;


script.js
export function todayYYYYMMDD({type = 'plain'} ={}) { const today = toYYYYMMDD(new Date()); const text = (() => { switch(type) { case 'plain': return `${today} `; case 'hash': return `#${today} `; case 'link': return `[${today}]`; } })(); insertText({text}); } export function todayHHMMSS() { const today = toHHMMSS(new Date()); insertText({text: `${today} `}); } export function todayYYYYMMDD_HHMMSS({type = 'plain'} ={}) { const now = new Date(); const today = toYYYYMMDD(now); const time = toHHMMSS(now); const text = (() => { switch(type) { case 'plain': return `${today} ${time} `; case 'hash': return `#${today} ${time} `; case 'link': return `[${today}] ${time} `; } })(); insertText({text}); }

#2021-03-13 01:40:15
#2021-02-04 06:19:22
#2021-01-05 15:43:57
#2021-01-03 09:15:35