{"version":3,"sources":["../src/applyOffset.ts"],"sourcesContent":["import { date } from \"./date\"\nimport { TimezoneToken, fixedLengthByOffset, offsetToSecs } from \"./common\"\nimport type { MaybeDateInput } from \"./types\"\n\n/**\n * Apply a given offset to a date, returning a new date with the offset\n * applied by adding or subtracting the given number of seconds.\n * @param [dateInput] - The date to apply the offset to. (default: current time)\n * @param [offset] - The offset to apply in the +-HHmm, +-HH:mm, +-HHmmss, or +-HH:mm:ss format.\n */\nexport function applyOffset(dateInput?: MaybeDateInput, offset = \"+00:00\"): Date {\n  const d = date(dateInput)\n  const len = fixedLengthByOffset(offset)\n  // 5 or 8 chars = no colons (ZZ format), 6 or 9 chars = with colons (Z format)\n  const token: TimezoneToken = len === 5 || len === 8 ? \"ZZ\" : \"Z\"\n  const timeDiffInSecs = offsetToSecs(offset, token)\n  return new Date(d.getTime() + timeDiffInSecs * 1000)\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAwB,qBAAqB,oBAAoB;AAS1D,SAAS,YAAY,WAA4B,SAAS,UAAgB;AAC/E,QAAM,IAAI,KAAK,SAAS;AACxB,QAAM,MAAM,oBAAoB,MAAM;AAEtC,QAAM,QAAuB,QAAQ,KAAK,QAAQ,IAAI,OAAO;AAC7D,QAAM,iBAAiB,aAAa,QAAQ,KAAK;AACjD,SAAO,IAAI,KAAK,EAAE,QAAQ,IAAI,iBAAiB,GAAI;AACrD;","names":[]}