MCPcopy
hub / github.com/jackwener/OpenCLI / formatShanghaiDate

Function formatShanghaiDate

clis/weibo/user-posts.js:41–50  ·  view source on GitHub ↗
(date)

Source from the content-addressed store, hash-verified

39}
40
41function formatShanghaiDate(date) {
42 const parts = new Intl.DateTimeFormat('en-CA', {
43 timeZone: 'Asia/Shanghai',
44 year: 'numeric',
45 month: '2-digit',
46 day: '2-digit',
47 }).formatToParts(date);
48 const get = (type) => parts.find((part) => part.type === type)?.value;
49 return `${get('year')}-${get('month')}-${get('day')}`;
50}
51
52function dateToTimestamp(date) {
53 return Math.floor(new Date(`${date}T00:00:00+08:00`).getTime() / 1000);

Callers 1

readDateFunction · 0.85

Calls 1

getFunction · 0.70

Tested by

no test coverage detected