MCPcopy Create free account
hub / github.com/DavidWells/analytics / localTime

Function localTime

packages/analytics-utils/src/localTime.js:6–11  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4 * via https://www.simoahava.com/analytics/improve-data-collection-with-four-custom-dimensions/
5 */
6export function localTime() {
7 const d = new Date()
8 const tzo = -d.getTimezoneOffset()
9 const dif = tzo >= 0 ? '+' : '-'
10 return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}.${pad(d.getMilliseconds())}${dif}${pad(tzo / 60)}:${pad(tzo % 60)}`
11}
12
13function pad(num) {
14 const norm = Math.abs(Math.floor(num))

Callers

nothing calls this directly

Calls 1

padFunction · 0.85

Tested by

no test coverage detected