push
github
Revert "chore: remove Gatsby frontend, keep Express API only (#915)" (#916) This reverts commit cf9460dd1.
302 of 415 branches covered (72.77%)
Branch coverage included in aggregate %.
125 of 135 new or added lines in 3 files covered. (92.59%)
3307 of 5194 relevant lines covered (63.67%)
2.82 hits per line
|
|
import Time from "decentraland-gatsby/dist/utils/date/Time"
|
1✔ |
|
|
|
1✔ |
|
|
/**
|
1✔ |
|
|
* Return a formatted label like (UTC) of with different timezone than UTC like (UTC -3) |
1✔ |
|
|
* @param time |
1✔ |
|
|
* @param useLocalTime |
1✔ |
|
|
* @returns |
1✔ |
|
|
*/ |
1✔ |
|
|
const showTimezoneLabel = (
|
|
|
|
time: Time.Dayjs | Date, |
24✔ |
|
|
useLocalTime: boolean | null | undefined = true
|
24✔ |
|
|
) => {
|
24✔ |
|
|
time = Time.from(time) |
24✔ |
|
|
if (!useLocalTime || time.isUTC()) {
|
|
|
|
return "(UTC)" |
5✔ |
|
|
} |
5✔ |
|
|
|
|
|
|
const zone = time.format("ZZ") // ±HHmm |
19✔ |
|
|
const sign = zone.slice(0, 1) |
19✔ |
|
|
const hours = zone.slice(1, 3) |
19✔ |
|
|
const minutes = zone.slice(3) |
19✔ |
|
|
|
19✔ |
|
|
if (hours === "00" && minutes === "00") { |
|
|
NEW
|
return "(UTC)" |
× |
|
NEW
|
} |
× |
|
|
|
|
|
|
let result = "(UTC" + sign + String(Number(hours))
|
19✔ |
|
|
|
19✔ |
|
|
if (minutes !== "00") { |
|
|
|
result += ":" + minutes
|
6✔ |
|
|
} |
6✔ |
|
|
|
|
|
|
result += ")"
|
19✔ |
|
|
|
19✔ |
|
|
return result
|
19✔ |
|
|
} |
19✔ |
|
|
|
1✔ |
|
|
export { showTimezoneLabel }
|
1✔ |