MCPcopy
hub / github.com/date-fns/date-fns / calcOffset

Function calcOffset

pkgs/tz/src/tzOffset/index.ts:52–61  ·  view source on GitHub ↗
(cacheStr: string, values: string[])

Source from the content-addressed store, hash-verified

50const offsetRe = /([+-]\d\d):?(\d\d)?/;
51
52function calcOffset(cacheStr: string, values: string[]): number {
53 const hours = +(values[0] || 0);
54 const minutes = +(values[1] || 0);
55 // Convert seconds to minutes by dividing by 60 to keep the function return in minutes.
56 const seconds = +(values[2] || 0) / 60;
57 return (offsetCache[cacheStr] =
58 hours * 60 + minutes > 0
59 ? hours * 60 + minutes + seconds
60 : hours * 60 - minutes - seconds);
61}

Callers 1

tzOffsetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected