MCPcopy Create free account
hub / github.com/cloudflare/computer / formatGitTimestamp

Function formatGitTimestamp

packages/computer/src/git/cli.ts:828–843  ·  view source on GitHub ↗
(timestamp: number, timezoneOffset: number)

Source from the content-addressed store, hash-verified

826}
827
828function formatGitTimestamp(timestamp: number, timezoneOffset: number): string {
829 // isomorphic-git stores timezoneOffset as minutes east of UTC,
830 // but git's wire format is `git log`'s output uses minutes
831 // west (the inverse). The two are negatives of each other;
832 // pick the convention real git users see.
833 const d = new Date(timestamp * 1000);
834 const offsetMinutes = -timezoneOffset;
835 const sign = offsetMinutes >= 0 ? "+" : "-";
836 const abs = Math.abs(offsetMinutes);
837 const hh = String(Math.floor(abs / 60)).padStart(2, "0");
838 const mm = String(abs % 60).padStart(2, "0");
839 return `${d
840 .toISOString()
841 .replace("T", " ")
842 .replace(/\.\d{3}Z$/, "")} ${sign}${hh}${mm}`;
843}
844
845// ---------------------------------------------------------------
846// show

Callers 1

formatLogFullFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected