(timestamp: number, timezoneOffset: number)
| 826 | } |
| 827 | |
| 828 | function 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 |
no test coverage detected