@digitalwalletcorp/utils 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ import c from "crypto-js";
2
+ const u = {
3
+ ascii: "!\"#$%&'()*+,-./0123456789:;<=>?@[]^_`abcdefghijklmnopqrstuvwxyz{|}~",
4
+ number: "0123456789",
5
+ alphabet: "abcdefghijklmnopqrstuvwxyz",
6
+ alphanum: "0123456789abcdefghijklmnopqrstuvwxyz",
7
+ hex: "0123456789abcdef"
8
+ }, d = (e) => globalThis.crypto.getRandomValues(new Uint8Array(e));
9
+ function f(e) {
10
+ return c.SHA256(e).toString().toUpperCase();
11
+ }
12
+ function g(e, r) {
13
+ if (!Number.isInteger(e) || e < 0)
14
+ throw new Error("crypto-util.generateRandomString: length must be a non-negative integer");
15
+ const t = u[r?.charset ?? "ascii"], a = t.toUpperCase();
16
+ let i = r?.case === "upperCase" ? a : r?.case === "lowerCase" ? t : t + a;
17
+ const s = r?.includeChars;
18
+ s && (i += Array.isArray(s) ? s.join("") : s);
19
+ const l = r?.excludeChars;
20
+ if (l) {
21
+ const y = new Set(Array.isArray(l) ? l : Array.from(l));
22
+ i = Array.from(i).filter((h) => !y.has(h)).join("");
23
+ }
24
+ const o = Array.from(new Set(i));
25
+ if (!o.length)
26
+ throw new Error("crypto-util.generateRandomString: no characters left after applying excludeChars");
27
+ const p = Math.floor(256 / o.length) * o.length - 1;
28
+ let n = "";
29
+ do
30
+ for (n = ""; n.length < e; )
31
+ for (const y of d(e - n.length))
32
+ y <= p && (n += o[y % o.length]);
33
+ while (r?.rejectStartsWithZero && n.startsWith("0"));
34
+ return n;
35
+ }
36
+ function S(e, r) {
37
+ try {
38
+ return c.AES.encrypt(e, r).toString();
39
+ } catch {
40
+ throw new Error("crypto-util.encryptAES: plainText contains an unpaired surrogate");
41
+ }
42
+ }
43
+ function w(e, r) {
44
+ const t = c.format.OpenSSL.parse(e).ciphertext;
45
+ if (!t.sigBytes || t.sigBytes % 16 !== 0)
46
+ throw new Error("crypto-util.decryptAES: encryptedText is not a valid ciphertext");
47
+ const a = c.AES.decrypt(e, r);
48
+ if (a.sigBytes < 0)
49
+ throw new Error("crypto-util.decryptAES: failed to decrypt. The key may be wrong");
50
+ try {
51
+ return a.toString(c.enc.Utf8);
52
+ } catch {
53
+ throw new Error("crypto-util.decryptAES: failed to decrypt. The key may be wrong");
54
+ }
55
+ }
56
+ const A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
57
+ __proto__: null,
58
+ decryptAES: w,
59
+ encryptAES: S,
60
+ generateRandomString: g,
61
+ toSha256: f
62
+ }, Symbol.toStringTag, { value: "Module" }));
63
+ export {
64
+ A as c,
65
+ w as d,
66
+ S as e,
67
+ g,
68
+ f as t
69
+ };
70
+ //# sourceMappingURL=crypto-util-B5K2CmE2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto-util-B5K2CmE2.js","sources":["../src/crypto-util.ts"],"sourcesContent":["import CryptoJS from 'crypto-js';\n\nconst CHARSETS = {\n ascii: `!\"#$%&'()*+,-./0123456789:;<=>?@[]^_\\`abcdefghijklmnopqrstuvwxyz{|}~`,\n number: '0123456789',\n alphabet: 'abcdefghijklmnopqrstuvwxyz',\n alphanum: '0123456789abcdefghijklmnopqrstuvwxyz',\n hex: '0123456789abcdef'\n} as const;\n\nconst randomBytes = (size: number): Uint8Array => globalThis.crypto.getRandomValues(new Uint8Array(size));\n\n/**\n * 文字列をSHA-256でハッシュ化し、大文字の16進数文字列で返す\n *\n * @param {string} str\n * @returns {string}\n */\nexport function toSha256(str: string): string {\n return CryptoJS.SHA256(str).toString().toUpperCase();\n}\n\n/**\n * ランダムな文字列を生成する\n * 大文字と小文字は別の文字として扱う\n * caseを指定しない場合は生成対象の文字セットに大文字と小文字の両方を含めるため、'a'と'A'の出現率は同じ確率になる\n *\n * @param {number} length 生成する文字列の桁数\n * @param {*} [options]\n * ├ charset 'ascii' | 'number' | 'alphabet' | 'alphanum' | 'hex' 未指定の場合はASCIIの記号・数字・英字(スペースとバックスラッシュを除く)\n * ├ case 'upperCase' | 'lowerCase' 英字を大文字のみ・小文字のみにする。未指定の場合は大文字小文字混在\n * ├ rejectStartsWithZero trueを指定した場合、0始まりの文字列を生成しない\n * ├ includeChars 文字セットに追加する文字。大文字小文字を区別する\n * ├ excludeChars 文字セットから除外する文字。大文字小文字は区別する\n * @returns {string}\n */\nexport function generateRandomString(length: number, options?: {\n charset?: 'ascii' | 'number' | 'alphabet' | 'alphanum' | 'hex';\n case?: 'upperCase' | 'lowerCase';\n rejectStartsWithZero?: boolean;\n includeChars?: string | string[];\n excludeChars?: string | string[];\n}): string {\n if (!Number.isInteger(length) || length < 0) {\n throw new Error('crypto-util.generateRandomString: length must be a non-negative integer');\n }\n\n const lower = CHARSETS[options?.charset ?? 'ascii'];\n const upper = lower.toUpperCase();\n let pool = options?.case === 'upperCase'\n ? upper\n : options?.case === 'lowerCase'\n ? lower\n : lower + upper;\n const includeChars = options?.includeChars;\n if (includeChars) {\n // 追加文字の指定がある場合\n pool += Array.isArray(includeChars) ? includeChars.join('') : includeChars;\n }\n const excludeChars = options?.excludeChars;\n if (excludeChars) {\n // 除外文字の指定がある場合\n const excluded = new Set(Array.isArray(excludeChars) ? excludeChars : Array.from(excludeChars));\n pool = Array.from(pool).filter(a => !excluded.has(a)).join('');\n }\n const characters = Array.from(new Set(pool));\n if (!characters.length) {\n throw new Error('crypto-util.generateRandomString: no characters left after applying excludeChars');\n }\n // 256を文字種の数で割り切れる範囲のバイトだけを使い、文字ごとの出現率を揃える\n const maxAcceptableValue = Math.floor(256 / characters.length) * characters.length - 1;\n let result = '';\n do {\n result = '';\n while (result.length < length) {\n for (const byte of randomBytes(length - result.length)) {\n if (byte <= maxAcceptableValue) {\n result += characters[byte % characters.length];\n }\n }\n }\n } while (options?.rejectStartsWithZero && result.startsWith('0'));\n return result;\n}\n\n/**\n * 文字列をAESで暗号化し、Base64の文字列で返す\n * OpenSSL互換のパスフレーズ方式で、saltを毎回ランダムに生成するため同じ入力でも結果は毎回異なる\n *\n * @param {string} plainText\n * @param {string} key パスフレーズ\n * @returns {string}\n */\nexport function encryptAES(plainText: string, key: string): string {\n try {\n return CryptoJS.AES.encrypt(plainText, key).toString();\n } catch {\n // UTF-8に変換できない文字列(サロゲートペアの片割れを含む)はURIErrorになるので、原因が分かるメッセージに置き換える\n throw new Error('crypto-util.encryptAES: plainText contains an unpaired surrogate');\n }\n}\n\n/**\n * encryptAESで暗号化した文字列を復号する\n * 暗号文の形式が不正な場合と、復号に失敗したことが分かる場合は例外を投げる\n * (鍵違いは確実には検出できない。復号結果がたまたまパディングとUTF-8として成立すると、空文字や意味のない文字列が返ることがある)\n *\n * @param {string} encryptedText\n * @param {string} key パスフレーズ\n * @returns {string}\n */\nexport function decryptAES(encryptedText: string, key: string): string {\n const ciphertext = CryptoJS.format.OpenSSL.parse(encryptedText).ciphertext;\n if (!ciphertext.sigBytes || ciphertext.sigBytes % 16 !== 0) {\n throw new Error('crypto-util.decryptAES: encryptedText is not a valid ciphertext');\n }\n const decrypted = CryptoJS.AES.decrypt(encryptedText, key);\n // 鍵が違うとパディングが壊れて長さが負になる\n if (decrypted.sigBytes < 0) {\n throw new Error('crypto-util.decryptAES: failed to decrypt. The key may be wrong');\n }\n try {\n return decrypted.toString(CryptoJS.enc.Utf8);\n } catch {\n // パディングは成立したが復号結果がUTF-8として不正な場合も鍵違い\n throw new Error('crypto-util.decryptAES: failed to decrypt. The key may be wrong');\n }\n}\n"],"names":["CHARSETS","randomBytes","size","toSha256","str","CryptoJS","generateRandomString","length","options","lower","upper","pool","includeChars","excludeChars","excluded","a","characters","maxAcceptableValue","result","byte","encryptAES","plainText","key","decryptAES","encryptedText","ciphertext","decrypted"],"mappings":";AAEA,MAAMA,IAAW;AAAA,EACf,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AAAA,E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;AACT;AAUO,SAASE,EAAWC,GAAmBC,GAAqB;AACjE,MAAI;AACF,WAAOjB,EAAS,IAAI,QAAQgB,GAAWC,CAAG,EAAE,SAAA;AAAA,EAC9C,QAAQ;AAEN,UAAM,IAAI,MAAM,kEAAkE;AAAA,EACpF;AACF;AAWO,SAASC,EAAWC,GAAuBF,GAAqB;AACrE,QAAMG,IAAapB,EAAS,OAAO,QAAQ,MAAMmB,CAAa,EAAE;AAChE,MAAI,CAACC,EAAW,YAAYA,EAAW,WAAW,OAAO;AACvD,UAAM,IAAI,MAAM,iEAAiE;AAEnF,QAAMC,IAAYrB,EAAS,IAAI,QAAQmB,GAAeF,CAAG;AAEzD,MAAII,EAAU,WAAW;AACvB,UAAM,IAAI,MAAM,iEAAiE;AAEnF,MAAI;AACF,WAAOA,EAAU,SAASrB,EAAS,IAAI,IAAI;AAAA,EAC7C,QAAQ;AAEN,UAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AACF;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const c=require("crypto-js"),S={ascii:"!\"#$%&'()*+,-./0123456789:;<=>?@[]^_`abcdefghijklmnopqrstuvwxyz{|}~",number:"0123456789",alphabet:"abcdefghijklmnopqrstuvwxyz",alphanum:"0123456789abcdefghijklmnopqrstuvwxyz",hex:"0123456789abcdef"},w=e=>globalThis.crypto.getRandomValues(new Uint8Array(e));function p(e){return c.SHA256(e).toString().toUpperCase()}function h(e,r){if(!Number.isInteger(e)||e<0)throw new Error("crypto-util.generateRandomString: length must be a non-negative integer");const t=S[r?.charset??"ascii"],o=t.toUpperCase();let i=r?.case==="upperCase"?o:r?.case==="lowerCase"?t:t+o;const s=r?.includeChars;s&&(i+=Array.isArray(s)?s.join(""):s);const l=r?.excludeChars;if(l){const y=new Set(Array.isArray(l)?l:Array.from(l));i=Array.from(i).filter(f=>!y.has(f)).join("")}const a=Array.from(new Set(i));if(!a.length)throw new Error("crypto-util.generateRandomString: no characters left after applying excludeChars");const g=Math.floor(256/a.length)*a.length-1;let n="";do for(n="";n.length<e;)for(const y of w(e-n.length))y<=g&&(n+=a[y%a.length]);while(r?.rejectStartsWithZero&&n.startsWith("0"));return n}function u(e,r){try{return c.AES.encrypt(e,r).toString()}catch{throw new Error("crypto-util.encryptAES: plainText contains an unpaired surrogate")}}function d(e,r){const t=c.format.OpenSSL.parse(e).ciphertext;if(!t.sigBytes||t.sigBytes%16!==0)throw new Error("crypto-util.decryptAES: encryptedText is not a valid ciphertext");const o=c.AES.decrypt(e,r);if(o.sigBytes<0)throw new Error("crypto-util.decryptAES: failed to decrypt. The key may be wrong");try{return o.toString(c.enc.Utf8)}catch{throw new Error("crypto-util.decryptAES: failed to decrypt. The key may be wrong")}}const m=Object.freeze(Object.defineProperty({__proto__:null,decryptAES:d,encryptAES:u,generateRandomString:h,toSha256:p},Symbol.toStringTag,{value:"Module"}));exports.cryptoUtil=m;exports.decryptAES=d;exports.encryptAES=u;exports.generateRandomString=h;exports.toSha256=p;
2
+ //# sourceMappingURL=crypto-util-BcHurtbE.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto-util-BcHurtbE.cjs","sources":["../src/crypto-util.ts"],"sourcesContent":["import CryptoJS from 'crypto-js';\n\nconst CHARSETS = {\n ascii: `!\"#$%&'()*+,-./0123456789:;<=>?@[]^_\\`abcdefghijklmnopqrstuvwxyz{|}~`,\n number: '0123456789',\n alphabet: 'abcdefghijklmnopqrstuvwxyz',\n alphanum: '0123456789abcdefghijklmnopqrstuvwxyz',\n hex: '0123456789abcdef'\n} as const;\n\nconst randomBytes = (size: number): Uint8Array => globalThis.crypto.getRandomValues(new Uint8Array(size));\n\n/**\n * 文字列をSHA-256でハッシュ化し、大文字の16進数文字列で返す\n *\n * @param {string} str\n * @returns {string}\n */\nexport function toSha256(str: string): string {\n return CryptoJS.SHA256(str).toString().toUpperCase();\n}\n\n/**\n * ランダムな文字列を生成する\n * 大文字と小文字は別の文字として扱う\n * caseを指定しない場合は生成対象の文字セットに大文字と小文字の両方を含めるため、'a'と'A'の出現率は同じ確率になる\n *\n * @param {number} length 生成する文字列の桁数\n * @param {*} [options]\n * ├ charset 'ascii' | 'number' | 'alphabet' | 'alphanum' | 'hex' 未指定の場合はASCIIの記号・数字・英字(スペースとバックスラッシュを除く)\n * ├ case 'upperCase' | 'lowerCase' 英字を大文字のみ・小文字のみにする。未指定の場合は大文字小文字混在\n * ├ rejectStartsWithZero trueを指定した場合、0始まりの文字列を生成しない\n * ├ includeChars 文字セットに追加する文字。大文字小文字を区別する\n * ├ excludeChars 文字セットから除外する文字。大文字小文字は区別する\n * @returns {string}\n */\nexport function generateRandomString(length: number, options?: {\n charset?: 'ascii' | 'number' | 'alphabet' | 'alphanum' | 'hex';\n case?: 'upperCase' | 'lowerCase';\n rejectStartsWithZero?: boolean;\n includeChars?: string | string[];\n excludeChars?: string | string[];\n}): string {\n if (!Number.isInteger(length) || length < 0) {\n throw new Error('crypto-util.generateRandomString: length must be a non-negative integer');\n }\n\n const lower = CHARSETS[options?.charset ?? 'ascii'];\n const upper = lower.toUpperCase();\n let pool = options?.case === 'upperCase'\n ? upper\n : options?.case === 'lowerCase'\n ? lower\n : lower + upper;\n const includeChars = options?.includeChars;\n if (includeChars) {\n // 追加文字の指定がある場合\n pool += Array.isArray(includeChars) ? includeChars.join('') : includeChars;\n }\n const excludeChars = options?.excludeChars;\n if (excludeChars) {\n // 除外文字の指定がある場合\n const excluded = new Set(Array.isArray(excludeChars) ? excludeChars : Array.from(excludeChars));\n pool = Array.from(pool).filter(a => !excluded.has(a)).join('');\n }\n const characters = Array.from(new Set(pool));\n if (!characters.length) {\n throw new Error('crypto-util.generateRandomString: no characters left after applying excludeChars');\n }\n // 256を文字種の数で割り切れる範囲のバイトだけを使い、文字ごとの出現率を揃える\n const maxAcceptableValue = Math.floor(256 / characters.length) * characters.length - 1;\n let result = '';\n do {\n result = '';\n while (result.length < length) {\n for (const byte of randomBytes(length - result.length)) {\n if (byte <= maxAcceptableValue) {\n result += characters[byte % characters.length];\n }\n }\n }\n } while (options?.rejectStartsWithZero && result.startsWith('0'));\n return result;\n}\n\n/**\n * 文字列をAESで暗号化し、Base64の文字列で返す\n * OpenSSL互換のパスフレーズ方式で、saltを毎回ランダムに生成するため同じ入力でも結果は毎回異なる\n *\n * @param {string} plainText\n * @param {string} key パスフレーズ\n * @returns {string}\n */\nexport function encryptAES(plainText: string, key: string): string {\n try {\n return CryptoJS.AES.encrypt(plainText, key).toString();\n } catch {\n // UTF-8に変換できない文字列(サロゲートペアの片割れを含む)はURIErrorになるので、原因が分かるメッセージに置き換える\n throw new Error('crypto-util.encryptAES: plainText contains an unpaired surrogate');\n }\n}\n\n/**\n * encryptAESで暗号化した文字列を復号する\n * 暗号文の形式が不正な場合と、復号に失敗したことが分かる場合は例外を投げる\n * (鍵違いは確実には検出できない。復号結果がたまたまパディングとUTF-8として成立すると、空文字や意味のない文字列が返ることがある)\n *\n * @param {string} encryptedText\n * @param {string} key パスフレーズ\n * @returns {string}\n */\nexport function decryptAES(encryptedText: string, key: string): string {\n const ciphertext = CryptoJS.format.OpenSSL.parse(encryptedText).ciphertext;\n if (!ciphertext.sigBytes || ciphertext.sigBytes % 16 !== 0) {\n throw new Error('crypto-util.decryptAES: encryptedText is not a valid ciphertext');\n }\n const decrypted = CryptoJS.AES.decrypt(encryptedText, key);\n // 鍵が違うとパディングが壊れて長さが負になる\n if (decrypted.sigBytes < 0) {\n throw new Error('crypto-util.decryptAES: failed to decrypt. The key may be wrong');\n }\n try {\n return decrypted.toString(CryptoJS.enc.Utf8);\n } catch {\n // パディングは成立したが復号結果がUTF-8として不正な場合も鍵違い\n throw new Error('crypto-util.decryptAES: failed to decrypt. The key may be wrong');\n }\n}\n"],"names":["CHARSETS","randomBytes","size","toSha256","str","CryptoJS","generateRandomString","length","options","lower","upper","pool","includeChars","excludeChars","excluded","a","characters","maxAcceptableValue","result","byte","encryptAES","plainText","key","decryptAES","encryptedText","ciphertext","decrypted"],"mappings":"0CAEMA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AAG,GAC/D,OAAOA,CACT,CAUO,SAASE,EAAWC,EAAmBC,EAAqB,CACjE,GAAI,CACF,OAAOjB,EAAS,IAAI,QAAQgB,EAAWC,CAAG,EAAE,SAAA,CAC9C,MAAQ,CAEN,MAAM,IAAI,MAAM,kEAAkE,CACpF,CACF,CAWO,SAASC,EAAWC,EAAuBF,EAAqB,CACrE,MAAMG,EAAapB,EAAS,OAAO,QAAQ,MAAMmB,CAAa,EAAE,WAChE,GAAI,CAACC,EAAW,UAAYA,EAAW,SAAW,KAAO,EACvD,MAAM,IAAI,MAAM,iEAAiE,EAEnF,MAAMC,EAAYrB,EAAS,IAAI,QAAQmB,EAAeF,CAAG,EAEzD,GAAII,EAAU,SAAW,EACvB,MAAM,IAAI,MAAM,iEAAiE,EAEnF,GAAI,CACF,OAAOA,EAAU,SAASrB,EAAS,IAAI,IAAI,CAC7C,MAAQ,CAEN,MAAM,IAAI,MAAM,iEAAiE,CACnF,CACF"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("crypto-js");const e=require("./crypto-util-DeZSGetI.cjs");exports.generateRandomString=e.generateRandomString;exports.toSha256=e.toSha256;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("crypto-js");const e=require("./crypto-util-BcHurtbE.cjs");exports.decryptAES=e.decryptAES;exports.encryptAES=e.encryptAES;exports.generateRandomString=e.generateRandomString;exports.toSha256=e.toSha256;
2
2
  //# sourceMappingURL=crypto-util.cjs.map
@@ -26,3 +26,22 @@ export declare function generateRandomString(length: number, options?: {
26
26
  includeChars?: string | string[];
27
27
  excludeChars?: string | string[];
28
28
  }): string;
29
+ /**
30
+ * 文字列をAESで暗号化し、Base64の文字列で返す
31
+ * OpenSSL互換のパスフレーズ方式で、saltを毎回ランダムに生成するため同じ入力でも結果は毎回異なる
32
+ *
33
+ * @param {string} plainText
34
+ * @param {string} key パスフレーズ
35
+ * @returns {string}
36
+ */
37
+ export declare function encryptAES(plainText: string, key: string): string;
38
+ /**
39
+ * encryptAESで暗号化した文字列を復号する
40
+ * 暗号文の形式が不正な場合と、復号に失敗したことが分かる場合は例外を投げる
41
+ * (鍵違いは確実には検出できない。復号結果がたまたまパディングとUTF-8として成立すると、空文字や意味のない文字列が返ることがある)
42
+ *
43
+ * @param {string} encryptedText
44
+ * @param {string} key パスフレーズ
45
+ * @returns {string}
46
+ */
47
+ export declare function decryptAES(encryptedText: string, key: string): string;
@@ -26,3 +26,22 @@ export declare function generateRandomString(length: number, options?: {
26
26
  includeChars?: string | string[];
27
27
  excludeChars?: string | string[];
28
28
  }): string;
29
+ /**
30
+ * 文字列をAESで暗号化し、Base64の文字列で返す
31
+ * OpenSSL互換のパスフレーズ方式で、saltを毎回ランダムに生成するため同じ入力でも結果は毎回異なる
32
+ *
33
+ * @param {string} plainText
34
+ * @param {string} key パスフレーズ
35
+ * @returns {string}
36
+ */
37
+ export declare function encryptAES(plainText: string, key: string): string;
38
+ /**
39
+ * encryptAESで暗号化した文字列を復号する
40
+ * 暗号文の形式が不正な場合と、復号に失敗したことが分かる場合は例外を投げる
41
+ * (鍵違いは確実には検出できない。復号結果がたまたまパディングとUTF-8として成立すると、空文字や意味のない文字列が返ることがある)
42
+ *
43
+ * @param {string} encryptedText
44
+ * @param {string} key パスフレーズ
45
+ * @returns {string}
46
+ */
47
+ export declare function decryptAES(encryptedText: string, key: string): string;
@@ -1,7 +1,9 @@
1
1
  import "crypto-js";
2
- import { g as r, t as e } from "./crypto-util-DFJqfmuw.js";
2
+ import { d as r, e as o, g as n, t as p } from "./crypto-util-B5K2CmE2.js";
3
3
  export {
4
- r as generateRandomString,
5
- e as toSha256
4
+ r as decryptAES,
5
+ o as encryptAES,
6
+ n as generateRandomString,
7
+ p as toSha256
6
8
  };
7
9
  //# sourceMappingURL=crypto-util.js.map
@@ -1,5 +1,5 @@
1
- import { Duration as T, DateTime as s } from "luxon";
2
- const f = "UTC", m = "yyyy-MM-dd'T'HH:mm:ss.SSSZZ", S = 25569, E = 1440 * 60 * 1e3, A = 3600 * 1e3, D = /GMT[+-]\d{1,2}(:\d{2})?/g, g = {
1
+ import { Duration as m, DateTime as d } from "luxon";
2
+ const l = "UTC", S = "yyyy-MM-dd'T'HH:mm:ss.SSSZZ", E = 25569, A = 1440 * 60 * 1e3, D = 3600 * 1e3, g = /GMT[+-]\d{1,2}(:\d{2})?/g, y = {
3
3
  UTC: { standard: "UTC" },
4
4
  "Asia/Tokyo": { standard: "JST" },
5
5
  "Asia/Seoul": { standard: "KST" },
@@ -30,69 +30,71 @@ const f = "UTC", m = "yyyy-MM-dd'T'HH:mm:ss.SSSZZ", S = 25569, E = 1440 * 60 * 1
30
30
  "America/Vancouver": { standard: "PST", daylight: "PDT" },
31
31
  "America/Mexico_City": { standard: "CST" },
32
32
  "America/Sao_Paulo": { standard: "BRT" }
33
- }, u = (a) => {
33
+ }, f = (a) => {
34
34
  if (!a.isValid && a.invalidReason === "unsupported zone")
35
35
  throw new RangeError(a.invalidExplanation ?? a.invalidReason);
36
36
  }, i = (a, t) => {
37
37
  if (a == null || a === "")
38
38
  return null;
39
- const n = t?.inputTimezone ?? f;
39
+ const n = t?.inputTimezone ?? l;
40
40
  let r = null;
41
41
  if (a instanceof Date)
42
- r = s.fromJSDate(a, { zone: n });
42
+ r = d.fromJSDate(a, { zone: n });
43
43
  else if (typeof a == "number")
44
- r = Number.isFinite(a) ? s.fromMillis(a, { zone: n }) : null;
44
+ r = Number.isFinite(a) ? d.fromMillis(a, { zone: n }) : null;
45
45
  else {
46
46
  const e = t?.inputFormat ? [t.inputFormat].flat() : [];
47
- for (const d of e) {
48
- const o = s.fromFormat(a, d, { zone: n });
49
- if (u(o), o.isValid) {
47
+ for (const s of e) {
48
+ const o = d.fromFormat(a, s, { zone: n });
49
+ if (f(o), o.isValid) {
50
50
  r = o;
51
51
  break;
52
52
  }
53
53
  }
54
- r == null && (r = s.fromISO(a, { zone: n }));
54
+ r == null && (r = d.fromISO(a, { zone: n }));
55
55
  }
56
- return r == null || (u(r), !r.isValid) ? null : (t?.duration && (r = r.plus(t.duration)), t?.startOf && (r = r.startOf(t.startOf)), t?.endOf && (r = r.endOf(t.endOf)), r);
57
- }, l = (a, t, n, r) => {
58
- const e = i(a, n), d = i(t, n);
59
- return !e || !d ? !1 : r(e.valueOf(), d.valueOf());
56
+ return r == null || (f(r), !r.isValid) ? null : (t?.duration && (r = r.plus(t.duration)), t?.startOf && (r = r.startOf(t.startOf)), t?.endOf && (r = r.endOf(t.endOf)), r);
57
+ }, u = (a, t, n, r) => {
58
+ const e = i(a, n), s = i(t, n);
59
+ return !e || !s ? !1 : r(e.valueOf(), s.valueOf());
60
60
  };
61
- function y(a, t) {
61
+ function O(a, t) {
62
62
  return i(a, t)?.toJSDate() ?? null;
63
63
  }
64
- function O(a, t) {
64
+ function T(a, t) {
65
+ if (typeof a == "object" && a !== null && !(a instanceof Date))
66
+ return T(/* @__PURE__ */ new Date(), a);
65
67
  if (a == null || a === "")
66
68
  return "";
67
69
  const n = i(a, t);
68
70
  if (!n)
69
71
  return t?.invalidText ?? "Invalid Date";
70
- const r = n.setZone(t?.outputTimezone ?? f);
71
- return u(r), t?.outputFormat ? r.toFormat(t.outputFormat) : r.toISO();
72
+ const r = n.setZone(t?.outputTimezone ?? l);
73
+ return f(r), t?.outputFormat ? r.toFormat(t.outputFormat) : r.toISO();
72
74
  }
73
75
  function C(a, t) {
74
76
  return i(a, t) != null;
75
77
  }
76
78
  function h(a, t, n) {
77
- return l(a, t, n, (r, e) => r === e);
79
+ return u(a, t, n, (r, e) => r === e);
78
80
  }
79
81
  function _(a, t, n) {
80
- return l(a, t, n, (r, e) => r < e);
82
+ return u(a, t, n, (r, e) => r < e);
81
83
  }
82
84
  function M(a, t, n) {
83
- return l(a, t, n, (r, e) => r <= e);
84
- }
85
- function I(a, t, n) {
86
- return l(a, t, n, (r, e) => e < r);
85
+ return u(a, t, n, (r, e) => r <= e);
87
86
  }
88
87
  function b(a, t, n) {
89
- return l(a, t, n, (r, e) => e <= r);
88
+ return u(a, t, n, (r, e) => e < r);
89
+ }
90
+ function I(a, t, n) {
91
+ return u(a, t, n, (r, e) => e <= r);
90
92
  }
91
93
  function p(a, t) {
92
94
  const n = i(a, t)?.startOf("day");
93
95
  if (!n)
94
96
  return !1;
95
- const r = s.now().setZone(t?.inputTimezone ?? f).startOf("day");
97
+ const r = d.now().setZone(t?.inputTimezone ?? l).startOf("day");
96
98
  return n.valueOf() < r.valueOf();
97
99
  }
98
100
  function P(a, t) {
@@ -100,85 +102,74 @@ function P(a, t) {
100
102
  return n != null && n.valueOf() < Date.now();
101
103
  }
102
104
  function F(a, t, n, r) {
103
- const e = i(a, r), d = i(t, r);
104
- if (!e || !d)
105
+ const e = i(a, r), s = i(t, r);
106
+ if (!e || !s)
105
107
  return NaN;
106
108
  const o = n.slice(0, -1);
107
- return e.startOf(o).diff(d.startOf(o), n).get(n);
108
- }
109
- function N(a = f) {
110
- const t = s.now().setZone(a).startOf("day");
111
- return u(t), t.toJSDate();
109
+ return e.startOf(o).diff(s.startOf(o), n).get(n);
112
110
  }
113
- function R() {
114
- return /* @__PURE__ */ new Date();
111
+ function N(a = l) {
112
+ const t = d.now().setZone(a);
113
+ return f(t), t.toFormat(S);
115
114
  }
116
- function Z(a = f) {
117
- const t = s.now().setZone(a);
118
- return u(t), t.toFormat(m);
115
+ function R(a, t) {
116
+ let n = (a - E) * A;
117
+ return t?.offset && (n -= t.offset * D), n;
119
118
  }
120
- function L(a, t) {
121
- let n = (a - S) * E;
122
- return t?.offset && (n -= t.offset * A), n;
123
- }
124
- function U(a, t, n) {
125
- return T.fromObject({ [t]: a }).as(n);
119
+ function L(a, t, n) {
120
+ return m.fromObject({ [t]: a }).as(n);
126
121
  }
127
122
  function c(a, t) {
128
- const n = { ...g, ...t?.abbreviations }[a];
123
+ const n = { ...y, ...t?.abbreviations }[a];
129
124
  if (!n)
130
125
  return null;
131
126
  if (n.daylight) {
132
- const r = s.fromJSDate(t?.at ?? /* @__PURE__ */ new Date(), { zone: a });
133
- if (u(r), r.isInDST)
127
+ const r = d.fromJSDate(t?.at ?? /* @__PURE__ */ new Date(), { zone: a });
128
+ if (f(r), r.isInDST)
134
129
  return n.daylight;
135
130
  }
136
131
  return n.standard;
137
132
  }
138
- function k(a, t, n) {
133
+ function U(a, t, n) {
139
134
  const r = c(t, n);
140
- return r == null ? a : a.replace(D, r);
135
+ return r == null ? a : a.replace(g, r);
141
136
  }
142
- const B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
137
+ const k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
143
138
  __proto__: null,
144
- applyTimezoneAbbr: k,
145
- convertExcelDateSerialToUnixTimeSerial: L,
146
- convertTimeUnit: U,
147
- currentDate: N,
148
- currentDateTime: R,
149
- currentTimestamp: Z,
139
+ applyTimezoneAbbr: U,
140
+ convertExcelDateSerialToUnixTimeSerial: R,
141
+ convertTimeUnit: L,
142
+ currentTimestamp: N,
150
143
  diff: F,
151
- formatDate: O,
144
+ formatDate: T,
152
145
  getTimezoneAbbr: c,
153
- isAfter: I,
146
+ isAfter: b,
154
147
  isBefore: _,
155
148
  isPastDate: p,
156
149
  isPastDateTime: P,
157
150
  isSame: h,
158
- isSameOrAfter: b,
151
+ isSameOrAfter: I,
159
152
  isSameOrBefore: M,
160
153
  isValid: C,
161
- parseDate: y
154
+ parseDate: O
162
155
  }, Symbol.toStringTag, { value: "Module" }));
163
156
  export {
164
- k as a,
165
- U as b,
166
- L as c,
167
- B as d,
157
+ U as a,
158
+ L as b,
159
+ R as c,
160
+ k as d,
168
161
  N as e,
169
- R as f,
170
- Z as g,
171
- F as h,
172
- O as i,
173
- c as j,
174
- I as k,
175
- _ as l,
176
- p as m,
177
- P as n,
178
- h as o,
179
- b as p,
180
- M as q,
181
- C as r,
182
- y as s
162
+ F as f,
163
+ T as g,
164
+ c as h,
165
+ b as i,
166
+ _ as j,
167
+ p as k,
168
+ P as l,
169
+ h as m,
170
+ I as n,
171
+ M as o,
172
+ C as p,
173
+ O as q
183
174
  };
184
- //# sourceMappingURL=date-util-CG7L8nSP.js.map
175
+ //# sourceMappingURL=date-util-B-g6dSaM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-util-B-g6dSaM.js","sources":["../src/date-util.ts"],"sourcesContent":["import { DateTime, Duration as LuxonDuration } from 'luxon';\nimport type { DateTimeUnit } from 'luxon';\n\n/** 日時として解釈する値。string はISO形式または inputFormat の書式、number は epoch ミリ秒 */\nexport type DateInput = string | Date | number | null | undefined;\n\n/** 日時の切り捨て(startOf / endOf)に使う単位 */\nexport type DateUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';\n\n/** 期間の単位 */\nexport type TimeUnit = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years';\n\n/** 日時の加算・減算に使う期間。負の値で減算になる */\nexport interface Duration {\n years?: number;\n quarters?: number;\n months?: number;\n weeks?: number;\n days?: number;\n hours?: number;\n minutes?: number;\n seconds?: number;\n milliseconds?: number;\n}\n\n/**\n * 日時を解釈するときのオプション\n */\nexport interface ParseDateOptions {\n /** 入力の書式。配列の場合は先頭から順に試す。いずれにも一致しない場合はISO形式として解釈する */\n inputFormat?: string | string[];\n /** ゾーン情報を含まない入力をどのタイムゾーンの日時とみなすか(IANA名)。既定は 'UTC' */\n inputTimezone?: string;\n /** 解釈した日時に加算する期間。startOf / endOf より先に適用する */\n duration?: Duration;\n /** 指定した単位の最初の時点に切り捨てる(month なら月初の00:00:00.000) */\n startOf?: DateUnit;\n /** 指定した単位の最後の時点に切り上げる(month なら月末の23:59:59.999) */\n endOf?: DateUnit;\n}\n\n/**\n * 日時を文字列にするときのオプション\n */\nexport interface FormatDateOptions extends ParseDateOptions {\n /** 出力の書式。省略時はISO形式 */\n outputFormat?: string;\n /** 出力に使うタイムゾーン(IANA名)。既定は 'UTC' */\n outputTimezone?: string;\n /** 日時として解釈できない値に対する出力。既定は 'Invalid Date' */\n invalidText?: string;\n}\n\n/** タイムゾーンの略称。夏時間のないタイムゾーンでは daylight を持たない */\nexport interface TimezoneAbbreviation {\n standard: string;\n daylight?: string;\n}\n\n/** IANA名をキーにしたタイムゾーンの略称の表 */\nexport type TimezoneAbbreviations = Record<string, TimezoneAbbreviation>;\n\n/**\n * タイムゾーンの略称を解決するときのオプション\n */\nexport interface TimezoneAbbrOptions {\n /** 夏時間かどうかを判定する時点。既定は現在時刻 */\n at?: Date;\n /** 既定の表に追加・上書きする略称 */\n abbreviations?: TimezoneAbbreviations;\n}\n\nconst DEFAULT_TIMEZONE = 'UTC';\n\nconst TIMESTAMP_FORMAT = `yyyy-MM-dd'T'HH:mm:ss.SSSZZ`;\n\n/** 1970-01-01 を表すExcelの日付シリアル値 */\nconst EXCEL_EPOCH_SERIAL = 25569;\n\nconst MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;\n\nconst MILLISECONDS_PER_HOUR = 60 * 60 * 1000;\n\nconst GMT_OFFSET = /GMT[+-]\\d{1,2}(:\\d{2})?/g;\n\n/**\n * 略称の既定の表。略称は世界で一意ではないため(CST は米国中部・中国などで使われる)、このライブラリが採用する表記である\n */\nconst DEFAULT_TIMEZONE_ABBREVIATIONS: TimezoneAbbreviations = {\n 'UTC': { standard: 'UTC' },\n 'Asia/Tokyo': { standard: 'JST' },\n 'Asia/Seoul': { standard: 'KST' },\n 'Asia/Shanghai': { standard: 'CST' },\n 'Asia/Hong_Kong': { standard: 'HKT' },\n 'Asia/Taipei': { standard: 'CST' },\n 'Asia/Singapore': { standard: 'SGT' },\n 'Asia/Manila': { standard: 'PHT' },\n 'Asia/Bangkok': { standard: 'ICT' },\n 'Asia/Ho_Chi_Minh': { standard: 'ICT' },\n 'Asia/Jakarta': { standard: 'WIB' },\n 'Asia/Kolkata': { standard: 'IST' },\n 'Asia/Dubai': { standard: 'GST' },\n 'Australia/Sydney': { standard: 'AEST', daylight: 'AEDT' },\n 'Pacific/Auckland': { standard: 'NZST', daylight: 'NZDT' },\n 'Europe/London': { standard: 'GMT', daylight: 'BST' },\n 'Europe/Paris': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Berlin': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Madrid': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Rome': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Amsterdam': { standard: 'CET', daylight: 'CEST' },\n 'America/New_York': { standard: 'EST', daylight: 'EDT' },\n 'America/Toronto': { standard: 'EST', daylight: 'EDT' },\n 'America/Chicago': { standard: 'CST', daylight: 'CDT' },\n 'America/Denver': { standard: 'MST', daylight: 'MDT' },\n 'America/Phoenix': { standard: 'MST' },\n 'America/Los_Angeles': { standard: 'PST', daylight: 'PDT' },\n 'America/Vancouver': { standard: 'PST', daylight: 'PDT' },\n 'America/Mexico_City': { standard: 'CST' },\n 'America/Sao_Paulo': { standard: 'BRT' }\n};\n\n/**\n * タイムゾーンの指定が不正な場合は、日時の不正とは区別して例外にする\n */\nconst assertZone = (d: DateTime): void => {\n if (!d.isValid && d.invalidReason === 'unsupported zone') {\n throw new RangeError(d.invalidExplanation ?? d.invalidReason);\n }\n};\n\nconst toDateTime = (value: DateInput, options?: ParseDateOptions): DateTime | null => {\n if (value == null || value === '') {\n return null;\n }\n const zone = options?.inputTimezone ?? DEFAULT_TIMEZONE;\n let d: DateTime | null = null;\n if (value instanceof Date) {\n d = DateTime.fromJSDate(value, { zone: zone });\n } else if (typeof value === 'number') {\n d = Number.isFinite(value) ? DateTime.fromMillis(value, { zone: zone }) : null;\n } else {\n const formats = options?.inputFormat ? [options.inputFormat].flat() : [];\n for (const format of formats) {\n const parsed = DateTime.fromFormat(value, format, { zone: zone });\n assertZone(parsed);\n if (parsed.isValid) {\n d = parsed;\n break;\n }\n }\n if (d == null) {\n d = DateTime.fromISO(value, { zone: zone });\n }\n }\n if (d == null) {\n return null;\n }\n assertZone(d);\n if (!d.isValid) {\n return null;\n }\n if (options?.duration) {\n d = d.plus(options.duration);\n }\n if (options?.startOf) {\n d = d.startOf(options.startOf);\n }\n if (options?.endOf) {\n d = d.endOf(options.endOf);\n }\n return d;\n};\n\nconst compare = (date1: DateInput, date2: DateInput, options: ParseDateOptions | undefined, predicate: (v1: number, v2: number) => boolean): boolean => {\n const d1 = toDateTime(date1, options);\n const d2 = toDateTime(date2, options);\n if (!d1 || !d2) {\n return false;\n }\n return predicate(d1.valueOf(), d2.valueOf());\n};\n\n/**\n * 値を日時として解釈し、Date を返す\n * duration / startOf / endOf は inputTimezone のゾーンで計算する\n * 解釈できない値、null / undefined / 空文字は null を返す。タイムゾーンの指定が不正な場合は RangeError をスローする\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {Date | null}\n */\nexport function parseDate(value: DateInput, options?: ParseDateOptions): Date | null {\n return toDateTime(value, options)?.toJSDate() ?? null;\n}\n\n/**\n * 値を日時として解釈し、outputTimezone での文字列にする\n * value を省略して options だけを渡した場合は現在時刻を整形する\n * null / undefined / 空文字は空文字を返す。解釈できない値は 'Invalid Date' を返す\n * タイムゾーンの指定が不正な場合は RangeError をスローする\n *\n * @param {DateInput} value\n * @param {FormatDateOptions} [options]\n * @returns {string}\n */\nexport function formatDate(options: FormatDateOptions): string;\nexport function formatDate(value: DateInput, options?: FormatDateOptions): string;\nexport function formatDate(value: DateInput | FormatDateOptions, options?: FormatDateOptions): string {\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) {\n return formatDate(new Date(), value);\n }\n if (value == null || value === '') {\n return '';\n }\n const d = toDateTime(value, options);\n if (!d) {\n return options?.invalidText ?? 'Invalid Date';\n }\n const output = d.setZone(options?.outputTimezone ?? DEFAULT_TIMEZONE);\n assertZone(output);\n return options?.outputFormat ? output.toFormat(options.outputFormat) : output.toISO() as string;\n}\n\n/**\n * 値が日時として解釈できるか判定する\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isValid(value: DateInput, options?: ParseDateOptions): boolean {\n return toDateTime(value, options) != null;\n}\n\n/**\n * date1 と date2 が同じ時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSame(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 === v2);\n}\n\n/**\n * date1 が date2 より前の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isBefore(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 < v2);\n}\n\n/**\n * date1 が date2 と同じか、より前の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSameOrBefore(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 <= v2);\n}\n\n/**\n * date1 が date2 より後の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isAfter(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v2 < v1);\n}\n\n/**\n * date1 が date2 と同じか、より後の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSameOrAfter(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v2 <= v1);\n}\n\n/**\n * 値が inputTimezone での今日より前の日付か判定する。解釈できない場合は false\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isPastDate(value: DateInput, options?: ParseDateOptions): boolean {\n const target = toDateTime(value, options)?.startOf('day');\n if (!target) {\n return false;\n }\n const today = DateTime.now().setZone(options?.inputTimezone ?? DEFAULT_TIMEZONE).startOf('day');\n return target.valueOf() < today.valueOf();\n}\n\n/**\n * 値が現在時刻より前か判定する。解釈できない場合は false\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isPastDateTime(value: DateInput, options?: ParseDateOptions): boolean {\n const target = toDateTime(value, options);\n return target != null && target.valueOf() < Date.now();\n}\n\n/**\n * date1 − date2 を unit の単位で返す\n * 両方を inputTimezone で unit の始まりに切り捨ててから差を取るため、暦の上での差になる(23:00 と翌 01:00 の days は 1)\n * どちらかが解釈できない場合は NaN を返す\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {TimeUnit} unit\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {number}\n */\nexport function diff(date1: DateInput, date2: DateInput, unit: TimeUnit, options?: ParseDateOptions): number {\n const d1 = toDateTime(date1, options);\n const d2 = toDateTime(date2, options);\n if (!d1 || !d2) {\n return NaN;\n }\n // 'days' → 'day' のように切り捨ての単位にする\n const dateUnit = unit.slice(0, -1) as DateTimeUnit;\n return d1.startOf(dateUnit).diff(d2.startOf(dateUnit), unit).get(unit);\n}\n\n/**\n * 現在時刻を timezone での 'yyyy-MM-ddTHH:mm:ss.SSS+HH:mm' 形式の文字列で返す\n *\n * @param {string} [timezone] IANA名。既定は 'UTC'\n * @returns {string}\n */\nexport function currentTimestamp(timezone: string = DEFAULT_TIMEZONE): string {\n const d = DateTime.now().setZone(timezone);\n assertZone(d);\n return d.toFormat(TIMESTAMP_FORMAT);\n}\n\n/**\n * Excelの日付シリアル値を epoch ミリ秒に変換する\n * Excelの日付シリアル値はゾーンの概念を持たないため、そのままではUTCの日時として変換される\n * シリアル値がどのゾーンの日時かが分かっている場合は offset に時間差を指定する\n *\n * @example\n * convertExcelDateSerialToUnixTimeSerial(45200); // 1696118400000 (2023-10-01T00:00:00Z)\n * convertExcelDateSerialToUnixTimeSerial(45200, { offset: 9 }); // 1696086000000 (2023-10-01T00:00:00+09:00)\n *\n * @param {number} excelDateSerial\n * @param {*} [options]\n * └ offset シリアル値のゾーンのUTCからの時間差(時)\n * @returns {number}\n */\nexport function convertExcelDateSerialToUnixTimeSerial(excelDateSerial: number, options?: {\n offset: number;\n}): number {\n let timeserial = (excelDateSerial - EXCEL_EPOCH_SERIAL) * MILLISECONDS_PER_DAY;\n if (options?.offset) {\n timeserial -= options.offset * MILLISECONDS_PER_HOUR;\n }\n return timeserial;\n}\n\n/**\n * 期間の値を別の単位に換算する\n * 月と年は固定長(1か月 = 30日、1年 = 365日)として換算する\n *\n * @example\n * convertTimeUnit(1, 'hours', 'milliseconds'); // 3600000\n *\n * @param {number} value\n * @param {TimeUnit} inputUnit\n * @param {TimeUnit} outputUnit\n * @returns {number}\n */\nexport function convertTimeUnit(value: number, inputUnit: TimeUnit, outputUnit: TimeUnit): number {\n return LuxonDuration.fromObject({ [inputUnit]: value }).as(outputUnit);\n}\n\n/**\n * タイムゾーンの略称を返す。夏時間の期間中は夏時間の略称を返す\n * 既定の表にない場合は null を返す。表は options.abbreviations で追加・上書きできる\n *\n * @param {string} timezone IANA名\n * @param {TimezoneAbbrOptions} [options]\n * @returns {string | null}\n */\nexport function getTimezoneAbbr(timezone: string, options?: TimezoneAbbrOptions): string | null {\n const definition = { ...DEFAULT_TIMEZONE_ABBREVIATIONS, ...options?.abbreviations }[timezone];\n if (!definition) {\n return null;\n }\n if (definition.daylight) {\n const d = DateTime.fromJSDate(options?.at ?? new Date(), { zone: timezone });\n assertZone(d);\n if (d.isInDST) {\n return definition.daylight;\n }\n }\n return definition.standard;\n}\n\n/**\n * 文字列中の 'GMT+9' のようなオフセット表記を、timezone の略称に置き換える\n * 略称が解決できない場合は文字列をそのまま返す\n *\n * @param {string} text\n * @param {string} timezone IANA名\n * @param {TimezoneAbbrOptions} [options]\n * @returns {string}\n */\nexport function applyTimezoneAbbr(text: string, timezone: string, options?: TimezoneAbbrOptions): string {\n const abbr = getTimezoneAbbr(timezone, options);\n return abbr == null ? text : text.replace(GMT_OFFSET, abbr);\n}\n"],"names":["DEFAULT_TIMEZONE","TIMESTAMP_FORMAT","EXCEL_EPOCH_SERIAL","MILLISECONDS_PER_DAY","MILLISECONDS_PER_HOUR","GMT_OFFSET","DEFAULT_TIMEZONE_ABBREVIATIONS","assertZone","d","toDateTime","value","options","zone","DateTime","formats","format","parsed","compare","date1","date2","predicate","d1","d2","parseDate","formatDate","output","isValid","isSame","v1","v2","isBefore","isSameOrBefore","isAfter","isSameOrAfter","isPastDate","target","today","isPastDateTime","diff","unit","dateUnit","currentTimestamp","timezone","convertExcelDateSerialToUnixTimeSerial","excelDateSerial","timeserial","convertTimeUnit","inputUnit","outputUnit","LuxonDuration","getTimezoneAbbr","definition","applyTimezoneAbbr","text","abbr"],"mappings":";AAwEA,MAAMA,IAAmB,OAEnBC,IAAmB,+BAGnBC,IAAqB,OAErBC,IAAuB,OAAU,KAAK,KAEtCC,IAAwB,OAAU,KAElCC,IAAa,4BAKbC,IAAwD;AAAA,EAC5D,KAAO,EAAE,UAAU,MAAA;AAAA,EACnB,cAAc,EAAE,UAAU,MAAA;AAAA,EAC1B,cAAc,EAAE,UAAU,MAAA;AAAA,EAC1B,iBAAiB,EAAE,UAAU,MAAA;AAAA,EAC7B,kBAAkB,EAAE,UAAU,MAAA;AAAA,EAC9B,eAAe,EAAE,UAAU,MAAA;AAAA,EAC3B,kBAAkB,EAAE,UAAU,MAAA;AAAA,EAC9B,eAAe,EAAE,UAAU,MAAA;AAAA,EAC3B,gBAAgB,EAAE,UAAU,MAAA;AAAA,EAC5B,oBAAoB,EAAE,UAAU,MAAA;AAAA,EAChC,gBAAgB,EAAE,UAAU,MAAA;AAAA,EAC5B,gB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,EAAkBC,GAAcX,GAAkB/B,GAAuC;AACvG,QAAM2C,IAAOJ,EAAgBR,GAAU/B,CAAO;AAC9C,SAAO2C,KAAQ,OAAOD,IAAOA,EAAK,QAAQhD,GAAYiD,CAAI;AAC5D;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const s=require("luxon"),T="UTC",I="yyyy-MM-dd'T'HH:mm:ss.SSSZZ",P=25569,F=1440*60*1e3,U=3600*1e3,B=/GMT[+-]\d{1,2}(:\d{2})?/g,N={UTC:{standard:"UTC"},"Asia/Tokyo":{standard:"JST"},"Asia/Seoul":{standard:"KST"},"Asia/Shanghai":{standard:"CST"},"Asia/Hong_Kong":{standard:"HKT"},"Asia/Taipei":{standard:"CST"},"Asia/Singapore":{standard:"SGT"},"Asia/Manila":{standard:"PHT"},"Asia/Bangkok":{standard:"ICT"},"Asia/Ho_Chi_Minh":{standard:"ICT"},"Asia/Jakarta":{standard:"WIB"},"Asia/Kolkata":{standard:"IST"},"Asia/Dubai":{standard:"GST"},"Australia/Sydney":{standard:"AEST",daylight:"AEDT"},"Pacific/Auckland":{standard:"NZST",daylight:"NZDT"},"Europe/London":{standard:"GMT",daylight:"BST"},"Europe/Paris":{standard:"CET",daylight:"CEST"},"Europe/Berlin":{standard:"CET",daylight:"CEST"},"Europe/Madrid":{standard:"CET",daylight:"CEST"},"Europe/Rome":{standard:"CET",daylight:"CEST"},"Europe/Amsterdam":{standard:"CET",daylight:"CEST"},"America/New_York":{standard:"EST",daylight:"EDT"},"America/Toronto":{standard:"EST",daylight:"EDT"},"America/Chicago":{standard:"CST",daylight:"CDT"},"America/Denver":{standard:"MST",daylight:"MDT"},"America/Phoenix":{standard:"MST"},"America/Los_Angeles":{standard:"PST",daylight:"PDT"},"America/Vancouver":{standard:"PST",daylight:"PDT"},"America/Mexico_City":{standard:"CST"},"America/Sao_Paulo":{standard:"BRT"}},f=t=>{if(!t.isValid&&t.invalidReason==="unsupported zone")throw new RangeError(t.invalidExplanation??t.invalidReason)},i=(t,a)=>{if(t==null||t==="")return null;const e=a?.inputTimezone??T;let n=null;if(t instanceof Date)n=s.DateTime.fromJSDate(t,{zone:e});else if(typeof t=="number")n=Number.isFinite(t)?s.DateTime.fromMillis(t,{zone:e}):null;else{const r=a?.inputFormat?[a.inputFormat].flat():[];for(const d of r){const o=s.DateTime.fromFormat(t,d,{zone:e});if(f(o),o.isValid){n=o;break}}n==null&&(n=s.DateTime.fromISO(t,{zone:e}))}return n==null||(f(n),!n.isValid)?null:(a?.duration&&(n=n.plus(a.duration)),a?.startOf&&(n=n.startOf(a.startOf)),a?.endOf&&(n=n.endOf(a.endOf)),n)},u=(t,a,e,n)=>{const r=i(t,e),d=i(a,e);return!r||!d?!1:n(r.valueOf(),d.valueOf())};function m(t,a){return i(t,a)?.toJSDate()??null}function l(t,a){if(typeof t=="object"&&t!==null&&!(t instanceof Date))return l(new Date,t);if(t==null||t==="")return"";const e=i(t,a);if(!e)return a?.invalidText??"Invalid Date";const n=e.setZone(a?.outputTimezone??T);return f(n),a?.outputFormat?n.toFormat(a.outputFormat):n.toISO()}function S(t,a){return i(t,a)!=null}function D(t,a,e){return u(t,a,e,(n,r)=>n===r)}function A(t,a,e){return u(t,a,e,(n,r)=>n<r)}function E(t,a,e){return u(t,a,e,(n,r)=>n<=r)}function y(t,a,e){return u(t,a,e,(n,r)=>r<n)}function O(t,a,e){return u(t,a,e,(n,r)=>r<=n)}function g(t,a){const e=i(t,a)?.startOf("day");if(!e)return!1;const n=s.DateTime.now().setZone(a?.inputTimezone??T).startOf("day");return e.valueOf()<n.valueOf()}function C(t,a){const e=i(t,a);return e!=null&&e.valueOf()<Date.now()}function h(t,a,e,n){const r=i(t,n),d=i(a,n);if(!r||!d)return NaN;const o=e.slice(0,-1);return r.startOf(o).diff(d.startOf(o),e).get(e)}function _(t=T){const a=s.DateTime.now().setZone(t);return f(a),a.toFormat(I)}function b(t,a){let e=(t-P)*F;return a?.offset&&(e-=a.offset*U),e}function M(t,a,e){return s.Duration.fromObject({[a]:t}).as(e)}function c(t,a){const e={...N,...a?.abbreviations}[t];if(!e)return null;if(e.daylight){const n=s.DateTime.fromJSDate(a?.at??new Date,{zone:t});if(f(n),n.isInDST)return e.daylight}return e.standard}function p(t,a,e){const n=c(a,e);return n==null?t:t.replace(B,n)}const R=Object.freeze(Object.defineProperty({__proto__:null,applyTimezoneAbbr:p,convertExcelDateSerialToUnixTimeSerial:b,convertTimeUnit:M,currentTimestamp:_,diff:h,formatDate:l,getTimezoneAbbr:c,isAfter:y,isBefore:A,isPastDate:g,isPastDateTime:C,isSame:D,isSameOrAfter:O,isSameOrBefore:E,isValid:S,parseDate:m},Symbol.toStringTag,{value:"Module"}));exports.applyTimezoneAbbr=p;exports.convertExcelDateSerialToUnixTimeSerial=b;exports.convertTimeUnit=M;exports.currentTimestamp=_;exports.dateUtil=R;exports.diff=h;exports.formatDate=l;exports.getTimezoneAbbr=c;exports.isAfter=y;exports.isBefore=A;exports.isPastDate=g;exports.isPastDateTime=C;exports.isSame=D;exports.isSameOrAfter=O;exports.isSameOrBefore=E;exports.isValid=S;exports.parseDate=m;
2
+ //# sourceMappingURL=date-util-DG-ujlhH.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-util-DG-ujlhH.cjs","sources":["../src/date-util.ts"],"sourcesContent":["import { DateTime, Duration as LuxonDuration } from 'luxon';\nimport type { DateTimeUnit } from 'luxon';\n\n/** 日時として解釈する値。string はISO形式または inputFormat の書式、number は epoch ミリ秒 */\nexport type DateInput = string | Date | number | null | undefined;\n\n/** 日時の切り捨て(startOf / endOf)に使う単位 */\nexport type DateUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';\n\n/** 期間の単位 */\nexport type TimeUnit = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years';\n\n/** 日時の加算・減算に使う期間。負の値で減算になる */\nexport interface Duration {\n years?: number;\n quarters?: number;\n months?: number;\n weeks?: number;\n days?: number;\n hours?: number;\n minutes?: number;\n seconds?: number;\n milliseconds?: number;\n}\n\n/**\n * 日時を解釈するときのオプション\n */\nexport interface ParseDateOptions {\n /** 入力の書式。配列の場合は先頭から順に試す。いずれにも一致しない場合はISO形式として解釈する */\n inputFormat?: string | string[];\n /** ゾーン情報を含まない入力をどのタイムゾーンの日時とみなすか(IANA名)。既定は 'UTC' */\n inputTimezone?: string;\n /** 解釈した日時に加算する期間。startOf / endOf より先に適用する */\n duration?: Duration;\n /** 指定した単位の最初の時点に切り捨てる(month なら月初の00:00:00.000) */\n startOf?: DateUnit;\n /** 指定した単位の最後の時点に切り上げる(month なら月末の23:59:59.999) */\n endOf?: DateUnit;\n}\n\n/**\n * 日時を文字列にするときのオプション\n */\nexport interface FormatDateOptions extends ParseDateOptions {\n /** 出力の書式。省略時はISO形式 */\n outputFormat?: string;\n /** 出力に使うタイムゾーン(IANA名)。既定は 'UTC' */\n outputTimezone?: string;\n /** 日時として解釈できない値に対する出力。既定は 'Invalid Date' */\n invalidText?: string;\n}\n\n/** タイムゾーンの略称。夏時間のないタイムゾーンでは daylight を持たない */\nexport interface TimezoneAbbreviation {\n standard: string;\n daylight?: string;\n}\n\n/** IANA名をキーにしたタイムゾーンの略称の表 */\nexport type TimezoneAbbreviations = Record<string, TimezoneAbbreviation>;\n\n/**\n * タイムゾーンの略称を解決するときのオプション\n */\nexport interface TimezoneAbbrOptions {\n /** 夏時間かどうかを判定する時点。既定は現在時刻 */\n at?: Date;\n /** 既定の表に追加・上書きする略称 */\n abbreviations?: TimezoneAbbreviations;\n}\n\nconst DEFAULT_TIMEZONE = 'UTC';\n\nconst TIMESTAMP_FORMAT = `yyyy-MM-dd'T'HH:mm:ss.SSSZZ`;\n\n/** 1970-01-01 を表すExcelの日付シリアル値 */\nconst EXCEL_EPOCH_SERIAL = 25569;\n\nconst MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;\n\nconst MILLISECONDS_PER_HOUR = 60 * 60 * 1000;\n\nconst GMT_OFFSET = /GMT[+-]\\d{1,2}(:\\d{2})?/g;\n\n/**\n * 略称の既定の表。略称は世界で一意ではないため(CST は米国中部・中国などで使われる)、このライブラリが採用する表記である\n */\nconst DEFAULT_TIMEZONE_ABBREVIATIONS: TimezoneAbbreviations = {\n 'UTC': { standard: 'UTC' },\n 'Asia/Tokyo': { standard: 'JST' },\n 'Asia/Seoul': { standard: 'KST' },\n 'Asia/Shanghai': { standard: 'CST' },\n 'Asia/Hong_Kong': { standard: 'HKT' },\n 'Asia/Taipei': { standard: 'CST' },\n 'Asia/Singapore': { standard: 'SGT' },\n 'Asia/Manila': { standard: 'PHT' },\n 'Asia/Bangkok': { standard: 'ICT' },\n 'Asia/Ho_Chi_Minh': { standard: 'ICT' },\n 'Asia/Jakarta': { standard: 'WIB' },\n 'Asia/Kolkata': { standard: 'IST' },\n 'Asia/Dubai': { standard: 'GST' },\n 'Australia/Sydney': { standard: 'AEST', daylight: 'AEDT' },\n 'Pacific/Auckland': { standard: 'NZST', daylight: 'NZDT' },\n 'Europe/London': { standard: 'GMT', daylight: 'BST' },\n 'Europe/Paris': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Berlin': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Madrid': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Rome': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Amsterdam': { standard: 'CET', daylight: 'CEST' },\n 'America/New_York': { standard: 'EST', daylight: 'EDT' },\n 'America/Toronto': { standard: 'EST', daylight: 'EDT' },\n 'America/Chicago': { standard: 'CST', daylight: 'CDT' },\n 'America/Denver': { standard: 'MST', daylight: 'MDT' },\n 'America/Phoenix': { standard: 'MST' },\n 'America/Los_Angeles': { standard: 'PST', daylight: 'PDT' },\n 'America/Vancouver': { standard: 'PST', daylight: 'PDT' },\n 'America/Mexico_City': { standard: 'CST' },\n 'America/Sao_Paulo': { standard: 'BRT' }\n};\n\n/**\n * タイムゾーンの指定が不正な場合は、日時の不正とは区別して例外にする\n */\nconst assertZone = (d: DateTime): void => {\n if (!d.isValid && d.invalidReason === 'unsupported zone') {\n throw new RangeError(d.invalidExplanation ?? d.invalidReason);\n }\n};\n\nconst toDateTime = (value: DateInput, options?: ParseDateOptions): DateTime | null => {\n if (value == null || value === '') {\n return null;\n }\n const zone = options?.inputTimezone ?? DEFAULT_TIMEZONE;\n let d: DateTime | null = null;\n if (value instanceof Date) {\n d = DateTime.fromJSDate(value, { zone: zone });\n } else if (typeof value === 'number') {\n d = Number.isFinite(value) ? DateTime.fromMillis(value, { zone: zone }) : null;\n } else {\n const formats = options?.inputFormat ? [options.inputFormat].flat() : [];\n for (const format of formats) {\n const parsed = DateTime.fromFormat(value, format, { zone: zone });\n assertZone(parsed);\n if (parsed.isValid) {\n d = parsed;\n break;\n }\n }\n if (d == null) {\n d = DateTime.fromISO(value, { zone: zone });\n }\n }\n if (d == null) {\n return null;\n }\n assertZone(d);\n if (!d.isValid) {\n return null;\n }\n if (options?.duration) {\n d = d.plus(options.duration);\n }\n if (options?.startOf) {\n d = d.startOf(options.startOf);\n }\n if (options?.endOf) {\n d = d.endOf(options.endOf);\n }\n return d;\n};\n\nconst compare = (date1: DateInput, date2: DateInput, options: ParseDateOptions | undefined, predicate: (v1: number, v2: number) => boolean): boolean => {\n const d1 = toDateTime(date1, options);\n const d2 = toDateTime(date2, options);\n if (!d1 || !d2) {\n return false;\n }\n return predicate(d1.valueOf(), d2.valueOf());\n};\n\n/**\n * 値を日時として解釈し、Date を返す\n * duration / startOf / endOf は inputTimezone のゾーンで計算する\n * 解釈できない値、null / undefined / 空文字は null を返す。タイムゾーンの指定が不正な場合は RangeError をスローする\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {Date | null}\n */\nexport function parseDate(value: DateInput, options?: ParseDateOptions): Date | null {\n return toDateTime(value, options)?.toJSDate() ?? null;\n}\n\n/**\n * 値を日時として解釈し、outputTimezone での文字列にする\n * value を省略して options だけを渡した場合は現在時刻を整形する\n * null / undefined / 空文字は空文字を返す。解釈できない値は 'Invalid Date' を返す\n * タイムゾーンの指定が不正な場合は RangeError をスローする\n *\n * @param {DateInput} value\n * @param {FormatDateOptions} [options]\n * @returns {string}\n */\nexport function formatDate(options: FormatDateOptions): string;\nexport function formatDate(value: DateInput, options?: FormatDateOptions): string;\nexport function formatDate(value: DateInput | FormatDateOptions, options?: FormatDateOptions): string {\n if (typeof value === 'object' && value !== null && !(value instanceof Date)) {\n return formatDate(new Date(), value);\n }\n if (value == null || value === '') {\n return '';\n }\n const d = toDateTime(value, options);\n if (!d) {\n return options?.invalidText ?? 'Invalid Date';\n }\n const output = d.setZone(options?.outputTimezone ?? DEFAULT_TIMEZONE);\n assertZone(output);\n return options?.outputFormat ? output.toFormat(options.outputFormat) : output.toISO() as string;\n}\n\n/**\n * 値が日時として解釈できるか判定する\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isValid(value: DateInput, options?: ParseDateOptions): boolean {\n return toDateTime(value, options) != null;\n}\n\n/**\n * date1 と date2 が同じ時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSame(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 === v2);\n}\n\n/**\n * date1 が date2 より前の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isBefore(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 < v2);\n}\n\n/**\n * date1 が date2 と同じか、より前の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSameOrBefore(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 <= v2);\n}\n\n/**\n * date1 が date2 より後の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isAfter(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v2 < v1);\n}\n\n/**\n * date1 が date2 と同じか、より後の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSameOrAfter(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v2 <= v1);\n}\n\n/**\n * 値が inputTimezone での今日より前の日付か判定する。解釈できない場合は false\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isPastDate(value: DateInput, options?: ParseDateOptions): boolean {\n const target = toDateTime(value, options)?.startOf('day');\n if (!target) {\n return false;\n }\n const today = DateTime.now().setZone(options?.inputTimezone ?? DEFAULT_TIMEZONE).startOf('day');\n return target.valueOf() < today.valueOf();\n}\n\n/**\n * 値が現在時刻より前か判定する。解釈できない場合は false\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isPastDateTime(value: DateInput, options?: ParseDateOptions): boolean {\n const target = toDateTime(value, options);\n return target != null && target.valueOf() < Date.now();\n}\n\n/**\n * date1 − date2 を unit の単位で返す\n * 両方を inputTimezone で unit の始まりに切り捨ててから差を取るため、暦の上での差になる(23:00 と翌 01:00 の days は 1)\n * どちらかが解釈できない場合は NaN を返す\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {TimeUnit} unit\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {number}\n */\nexport function diff(date1: DateInput, date2: DateInput, unit: TimeUnit, options?: ParseDateOptions): number {\n const d1 = toDateTime(date1, options);\n const d2 = toDateTime(date2, options);\n if (!d1 || !d2) {\n return NaN;\n }\n // 'days' → 'day' のように切り捨ての単位にする\n const dateUnit = unit.slice(0, -1) as DateTimeUnit;\n return d1.startOf(dateUnit).diff(d2.startOf(dateUnit), unit).get(unit);\n}\n\n/**\n * 現在時刻を timezone での 'yyyy-MM-ddTHH:mm:ss.SSS+HH:mm' 形式の文字列で返す\n *\n * @param {string} [timezone] IANA名。既定は 'UTC'\n * @returns {string}\n */\nexport function currentTimestamp(timezone: string = DEFAULT_TIMEZONE): string {\n const d = DateTime.now().setZone(timezone);\n assertZone(d);\n return d.toFormat(TIMESTAMP_FORMAT);\n}\n\n/**\n * Excelの日付シリアル値を epoch ミリ秒に変換する\n * Excelの日付シリアル値はゾーンの概念を持たないため、そのままではUTCの日時として変換される\n * シリアル値がどのゾーンの日時かが分かっている場合は offset に時間差を指定する\n *\n * @example\n * convertExcelDateSerialToUnixTimeSerial(45200); // 1696118400000 (2023-10-01T00:00:00Z)\n * convertExcelDateSerialToUnixTimeSerial(45200, { offset: 9 }); // 1696086000000 (2023-10-01T00:00:00+09:00)\n *\n * @param {number} excelDateSerial\n * @param {*} [options]\n * └ offset シリアル値のゾーンのUTCからの時間差(時)\n * @returns {number}\n */\nexport function convertExcelDateSerialToUnixTimeSerial(excelDateSerial: number, options?: {\n offset: number;\n}): number {\n let timeserial = (excelDateSerial - EXCEL_EPOCH_SERIAL) * MILLISECONDS_PER_DAY;\n if (options?.offset) {\n timeserial -= options.offset * MILLISECONDS_PER_HOUR;\n }\n return timeserial;\n}\n\n/**\n * 期間の値を別の単位に換算する\n * 月と年は固定長(1か月 = 30日、1年 = 365日)として換算する\n *\n * @example\n * convertTimeUnit(1, 'hours', 'milliseconds'); // 3600000\n *\n * @param {number} value\n * @param {TimeUnit} inputUnit\n * @param {TimeUnit} outputUnit\n * @returns {number}\n */\nexport function convertTimeUnit(value: number, inputUnit: TimeUnit, outputUnit: TimeUnit): number {\n return LuxonDuration.fromObject({ [inputUnit]: value }).as(outputUnit);\n}\n\n/**\n * タイムゾーンの略称を返す。夏時間の期間中は夏時間の略称を返す\n * 既定の表にない場合は null を返す。表は options.abbreviations で追加・上書きできる\n *\n * @param {string} timezone IANA名\n * @param {TimezoneAbbrOptions} [options]\n * @returns {string | null}\n */\nexport function getTimezoneAbbr(timezone: string, options?: TimezoneAbbrOptions): string | null {\n const definition = { ...DEFAULT_TIMEZONE_ABBREVIATIONS, ...options?.abbreviations }[timezone];\n if (!definition) {\n return null;\n }\n if (definition.daylight) {\n const d = DateTime.fromJSDate(options?.at ?? new Date(), { zone: timezone });\n assertZone(d);\n if (d.isInDST) {\n return definition.daylight;\n }\n }\n return definition.standard;\n}\n\n/**\n * 文字列中の 'GMT+9' のようなオフセット表記を、timezone の略称に置き換える\n * 略称が解決できない場合は文字列をそのまま返す\n *\n * @param {string} text\n * @param {string} timezone IANA名\n * @param {TimezoneAbbrOptions} [options]\n * @returns {string}\n */\nexport function applyTimezoneAbbr(text: string, timezone: string, options?: TimezoneAbbrOptions): string {\n const abbr = getTimezoneAbbr(timezone, options);\n return abbr == null ? text : text.replace(GMT_OFFSET, abbr);\n}\n"],"names":["DEFAULT_TIMEZONE","TIMESTAMP_FORMAT","EXCEL_EPOCH_SERIAL","MILLISECONDS_PER_DAY","MILLISECONDS_PER_HOUR","GMT_OFFSET","DEFAULT_TIMEZONE_ABBREVIATIONS","assertZone","d","toDateTime","value","options","zone","DateTime","formats","format","parsed","compare","date1","date2","predicate","d1","d2","parseDate","formatDate","output","isValid","isSame","v1","v2","isBefore","isSameOrBefore","isAfter","isSameOrAfter","isPastDate","target","today","isPastDateTime","diff","unit","dateUnit","currentTimestamp","timezone","convertExcelDateSerialToUnixTimeSerial","excelDateSerial","timeserial","convertTimeUnit","inputUnit","outputUnit","LuxonDuration","getTimezoneAbb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GrC,EAAO,EAAE,GAAGsC,CAAU,CACvE,CAUO,SAASE,EAAgBR,EAAkB/B,EAA8C,CAC9F,MAAMwC,EAAa,CAAE,GAAG7C,EAAgC,GAAGK,GAAS,aAAA,EAAgB+B,CAAQ,EAC5F,GAAI,CAACS,EACH,OAAO,KAET,GAAIA,EAAW,SAAU,CACvB,MAAM3C,EAAIK,EAAAA,SAAS,WAAWF,GAAS,IAAM,IAAI,KAAQ,CAAE,KAAM+B,EAAU,EAE3E,GADAnC,EAAWC,CAAC,EACRA,EAAE,QACJ,OAAO2C,EAAW,QAEtB,CACA,OAAOA,EAAW,QACpB,CAWO,SAASC,EAAkBC,EAAcX,EAAkB/B,EAAuC,CACvG,MAAM2C,EAAOJ,EAAgBR,EAAU/B,CAAO,EAC9C,OAAO2C,GAAQ,KAAOD,EAAOA,EAAK,QAAQhD,EAAYiD,CAAI,CAC5D"}
package/lib/date-util.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("luxon");const e=require("./date-util-DopNKy3u.cjs");exports.applyTimezoneAbbr=e.applyTimezoneAbbr;exports.convertExcelDateSerialToUnixTimeSerial=e.convertExcelDateSerialToUnixTimeSerial;exports.convertTimeUnit=e.convertTimeUnit;exports.currentDate=e.currentDate;exports.currentDateTime=e.currentDateTime;exports.currentTimestamp=e.currentTimestamp;exports.diff=e.diff;exports.formatDate=e.formatDate;exports.getTimezoneAbbr=e.getTimezoneAbbr;exports.isAfter=e.isAfter;exports.isBefore=e.isBefore;exports.isPastDate=e.isPastDate;exports.isPastDateTime=e.isPastDateTime;exports.isSame=e.isSame;exports.isSameOrAfter=e.isSameOrAfter;exports.isSameOrBefore=e.isSameOrBefore;exports.isValid=e.isValid;exports.parseDate=e.parseDate;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("luxon");const e=require("./date-util-DG-ujlhH.cjs");exports.applyTimezoneAbbr=e.applyTimezoneAbbr;exports.convertExcelDateSerialToUnixTimeSerial=e.convertExcelDateSerialToUnixTimeSerial;exports.convertTimeUnit=e.convertTimeUnit;exports.currentTimestamp=e.currentTimestamp;exports.diff=e.diff;exports.formatDate=e.formatDate;exports.getTimezoneAbbr=e.getTimezoneAbbr;exports.isAfter=e.isAfter;exports.isBefore=e.isBefore;exports.isPastDate=e.isPastDate;exports.isPastDateTime=e.isPastDateTime;exports.isSame=e.isSame;exports.isSameOrAfter=e.isSameOrAfter;exports.isSameOrBefore=e.isSameOrBefore;exports.isValid=e.isValid;exports.parseDate=e.parseDate;
2
2
  //# sourceMappingURL=date-util.cjs.map
@@ -70,13 +70,15 @@ export interface TimezoneAbbrOptions {
70
70
  export declare function parseDate(value: DateInput, options?: ParseDateOptions): Date | null;
71
71
  /**
72
72
  * 値を日時として解釈し、outputTimezone での文字列にする
73
- * null / undefined / 空文字は空文字を返す。解釈できない値は invalidText(既定 'Invalid Date')を返す
73
+ * value を省略して options だけを渡した場合は現在時刻を整形する
74
+ * null / undefined / 空文字は空文字を返す。解釈できない値は 'Invalid Date' を返す
74
75
  * タイムゾーンの指定が不正な場合は RangeError をスローする
75
76
  *
76
77
  * @param {DateInput} value
77
78
  * @param {FormatDateOptions} [options]
78
79
  * @returns {string}
79
80
  */
81
+ export declare function formatDate(options: FormatDateOptions): string;
80
82
  export declare function formatDate(value: DateInput, options?: FormatDateOptions): string;
81
83
  /**
82
84
  * 値が日時として解釈できるか判定する
@@ -159,20 +161,6 @@ export declare function isPastDateTime(value: DateInput, options?: ParseDateOpti
159
161
  * @returns {number}
160
162
  */
161
163
  export declare function diff(date1: DateInput, date2: DateInput, unit: TimeUnit, options?: ParseDateOptions): number;
162
- /**
163
- * timezone での今日の始まりを返す
164
- *
165
- * @param {string} [timezone] IANA名。既定は 'UTC'
166
- * @returns {Date}
167
- */
168
- export declare function currentDate(timezone?: string): Date;
169
- /**
170
- * 現在時刻を返す
171
- * Date はタイムゾーンを保持しないため、ゾーンは文字列にする時点(formatDate の outputTimezone)で指定する
172
- *
173
- * @returns {Date}
174
- */
175
- export declare function currentDateTime(): Date;
176
164
  /**
177
165
  * 現在時刻を timezone での 'yyyy-MM-ddTHH:mm:ss.SSS+HH:mm' 形式の文字列で返す
178
166
  *
@@ -70,13 +70,15 @@ export interface TimezoneAbbrOptions {
70
70
  export declare function parseDate(value: DateInput, options?: ParseDateOptions): Date | null;
71
71
  /**
72
72
  * 値を日時として解釈し、outputTimezone での文字列にする
73
- * null / undefined / 空文字は空文字を返す。解釈できない値は invalidText(既定 'Invalid Date')を返す
73
+ * value を省略して options だけを渡した場合は現在時刻を整形する
74
+ * null / undefined / 空文字は空文字を返す。解釈できない値は 'Invalid Date' を返す
74
75
  * タイムゾーンの指定が不正な場合は RangeError をスローする
75
76
  *
76
77
  * @param {DateInput} value
77
78
  * @param {FormatDateOptions} [options]
78
79
  * @returns {string}
79
80
  */
81
+ export declare function formatDate(options: FormatDateOptions): string;
80
82
  export declare function formatDate(value: DateInput, options?: FormatDateOptions): string;
81
83
  /**
82
84
  * 値が日時として解釈できるか判定する
@@ -159,20 +161,6 @@ export declare function isPastDateTime(value: DateInput, options?: ParseDateOpti
159
161
  * @returns {number}
160
162
  */
161
163
  export declare function diff(date1: DateInput, date2: DateInput, unit: TimeUnit, options?: ParseDateOptions): number;
162
- /**
163
- * timezone での今日の始まりを返す
164
- *
165
- * @param {string} [timezone] IANA名。既定は 'UTC'
166
- * @returns {Date}
167
- */
168
- export declare function currentDate(timezone?: string): Date;
169
- /**
170
- * 現在時刻を返す
171
- * Date はタイムゾーンを保持しないため、ゾーンは文字列にする時点(formatDate の outputTimezone)で指定する
172
- *
173
- * @returns {Date}
174
- */
175
- export declare function currentDateTime(): Date;
176
164
  /**
177
165
  * 現在時刻を timezone での 'yyyy-MM-ddTHH:mm:ss.SSS+HH:mm' 形式の文字列で返す
178
166
  *
package/lib/date-util.js CHANGED
@@ -1,23 +1,21 @@
1
1
  import "luxon";
2
- import { a as r, c as i, b as t, e as m, f as o, g as n, h as f, i as T, j as c, k as p, l as D, m as l, n as b, o as S, p as A, q as u, r as x, s as d } from "./date-util-CG7L8nSP.js";
2
+ import { a as i, c as r, b as t, e as m, f as o, g as f, h as n, i as p, j as T, k as l, l as b, m as c, n as D, o as S, p as A, q as x } from "./date-util-B-g6dSaM.js";
3
3
  export {
4
- r as applyTimezoneAbbr,
5
- i as convertExcelDateSerialToUnixTimeSerial,
4
+ i as applyTimezoneAbbr,
5
+ r as convertExcelDateSerialToUnixTimeSerial,
6
6
  t as convertTimeUnit,
7
- m as currentDate,
8
- o as currentDateTime,
9
- n as currentTimestamp,
10
- f as diff,
11
- T as formatDate,
12
- c as getTimezoneAbbr,
7
+ m as currentTimestamp,
8
+ o as diff,
9
+ f as formatDate,
10
+ n as getTimezoneAbbr,
13
11
  p as isAfter,
14
- D as isBefore,
12
+ T as isBefore,
15
13
  l as isPastDate,
16
14
  b as isPastDateTime,
17
- S as isSame,
18
- A as isSameOrAfter,
19
- u as isSameOrBefore,
20
- x as isValid,
21
- d as parseDate
15
+ c as isSame,
16
+ D as isSameOrAfter,
17
+ S as isSameOrBefore,
18
+ A as isValid,
19
+ x as parseDate
22
20
  };
23
21
  //# sourceMappingURL=date-util.js.map
package/lib/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./crypto-util-DeZSGetI.cjs"),i=require("./date-util-DopNKy3u.cjs"),e=require("./decimal.cjs"),l=require("./file-util-D09BvDYY.cjs"),r=require("./html-util-ClGIpzW1.cjs"),U=require("./json-util-5mq7fsX_.cjs"),o=require("./number-util-BaSf1wWH.cjs"),c=require("./object-util-6uts5Xax.cjs"),n=require("./string-util-w2I5EYuY.cjs");exports.CryptoUtil=t.cryptoUtil;exports.DateUtil=i.dateUtil;exports.Decimal=e.Decimal;exports.FileUtil=l.fileUtil;exports.HtmlUtil=r.htmlUtil;exports.JsonUtil=U.jsonUtil;exports.NumberUtil=o.numberUtil;exports.ObjectUtil=c.objectUtil;exports.StringUtil=n.stringUtil;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./crypto-util-BcHurtbE.cjs"),i=require("./date-util-DG-ujlhH.cjs"),e=require("./decimal.cjs"),l=require("./file-util-D09BvDYY.cjs"),r=require("./html-util-ClGIpzW1.cjs"),U=require("./json-util-5mq7fsX_.cjs"),o=require("./number-util-BaSf1wWH.cjs"),c=require("./object-util-6uts5Xax.cjs"),n=require("./string-util-w2I5EYuY.cjs");exports.CryptoUtil=t.cryptoUtil;exports.DateUtil=i.dateUtil;exports.Decimal=e.Decimal;exports.FileUtil=l.fileUtil;exports.HtmlUtil=r.htmlUtil;exports.JsonUtil=U.jsonUtil;exports.NumberUtil=o.numberUtil;exports.ObjectUtil=c.objectUtil;exports.StringUtil=n.stringUtil;
2
2
  //# sourceMappingURL=index.cjs.map
package/lib/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { c as r } from "./crypto-util-DFJqfmuw.js";
2
- import { d as m } from "./date-util-CG7L8nSP.js";
1
+ import { c as r } from "./crypto-util-B5K2CmE2.js";
2
+ import { d as m } from "./date-util-B-g6dSaM.js";
3
3
  import { Decimal as l } from "./decimal.js";
4
4
  import { f } from "./file-util-H-c_eQcd.js";
5
5
  import { h as s } from "./html-util-CcRJtzod.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalwalletcorp/utils",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "A javascript utility.",
5
5
  "type": "module",
6
6
  "main": "lib/index.cjs",
@@ -82,3 +82,47 @@ export function generateRandomString(length: number, options?: {
82
82
  } while (options?.rejectStartsWithZero && result.startsWith('0'));
83
83
  return result;
84
84
  }
85
+
86
+ /**
87
+ * 文字列をAESで暗号化し、Base64の文字列で返す
88
+ * OpenSSL互換のパスフレーズ方式で、saltを毎回ランダムに生成するため同じ入力でも結果は毎回異なる
89
+ *
90
+ * @param {string} plainText
91
+ * @param {string} key パスフレーズ
92
+ * @returns {string}
93
+ */
94
+ export function encryptAES(plainText: string, key: string): string {
95
+ try {
96
+ return CryptoJS.AES.encrypt(plainText, key).toString();
97
+ } catch {
98
+ // UTF-8に変換できない文字列(サロゲートペアの片割れを含む)はURIErrorになるので、原因が分かるメッセージに置き換える
99
+ throw new Error('crypto-util.encryptAES: plainText contains an unpaired surrogate');
100
+ }
101
+ }
102
+
103
+ /**
104
+ * encryptAESで暗号化した文字列を復号する
105
+ * 暗号文の形式が不正な場合と、復号に失敗したことが分かる場合は例外を投げる
106
+ * (鍵違いは確実には検出できない。復号結果がたまたまパディングとUTF-8として成立すると、空文字や意味のない文字列が返ることがある)
107
+ *
108
+ * @param {string} encryptedText
109
+ * @param {string} key パスフレーズ
110
+ * @returns {string}
111
+ */
112
+ export function decryptAES(encryptedText: string, key: string): string {
113
+ const ciphertext = CryptoJS.format.OpenSSL.parse(encryptedText).ciphertext;
114
+ if (!ciphertext.sigBytes || ciphertext.sigBytes % 16 !== 0) {
115
+ throw new Error('crypto-util.decryptAES: encryptedText is not a valid ciphertext');
116
+ }
117
+ const decrypted = CryptoJS.AES.decrypt(encryptedText, key);
118
+ // 鍵が違うとパディングが壊れて長さが負になる
119
+ if (decrypted.sigBytes < 0) {
120
+ throw new Error('crypto-util.decryptAES: failed to decrypt. The key may be wrong');
121
+ }
122
+ try {
123
+ return decrypted.toString(CryptoJS.enc.Utf8);
124
+ } catch {
125
+ // パディングは成立したが復号結果がUTF-8として不正な場合も鍵違い
126
+ throw new Error('crypto-util.decryptAES: failed to decrypt. The key may be wrong');
127
+ }
128
+ }
package/src/date-util.ts CHANGED
@@ -195,14 +195,20 @@ export function parseDate(value: DateInput, options?: ParseDateOptions): Date |
195
195
 
196
196
  /**
197
197
  * 値を日時として解釈し、outputTimezone での文字列にする
198
- * null / undefined / 空文字は空文字を返す。解釈できない値は invalidText(既定 'Invalid Date')を返す
198
+ * value を省略して options だけを渡した場合は現在時刻を整形する
199
+ * null / undefined / 空文字は空文字を返す。解釈できない値は 'Invalid Date' を返す
199
200
  * タイムゾーンの指定が不正な場合は RangeError をスローする
200
201
  *
201
202
  * @param {DateInput} value
202
203
  * @param {FormatDateOptions} [options]
203
204
  * @returns {string}
204
205
  */
205
- export function formatDate(value: DateInput, options?: FormatDateOptions): string {
206
+ export function formatDate(options: FormatDateOptions): string;
207
+ export function formatDate(value: DateInput, options?: FormatDateOptions): string;
208
+ export function formatDate(value: DateInput | FormatDateOptions, options?: FormatDateOptions): string {
209
+ if (typeof value === 'object' && value !== null && !(value instanceof Date)) {
210
+ return formatDate(new Date(), value);
211
+ }
206
212
  if (value == null || value === '') {
207
213
  return '';
208
214
  }
@@ -336,28 +342,6 @@ export function diff(date1: DateInput, date2: DateInput, unit: TimeUnit, options
336
342
  return d1.startOf(dateUnit).diff(d2.startOf(dateUnit), unit).get(unit);
337
343
  }
338
344
 
339
- /**
340
- * timezone での今日の始まりを返す
341
- *
342
- * @param {string} [timezone] IANA名。既定は 'UTC'
343
- * @returns {Date}
344
- */
345
- export function currentDate(timezone: string = DEFAULT_TIMEZONE): Date {
346
- const d = DateTime.now().setZone(timezone).startOf('day');
347
- assertZone(d);
348
- return d.toJSDate();
349
- }
350
-
351
- /**
352
- * 現在時刻を返す
353
- * Date はタイムゾーンを保持しないため、ゾーンは文字列にする時点(formatDate の outputTimezone)で指定する
354
- *
355
- * @returns {Date}
356
- */
357
- export function currentDateTime(): Date {
358
- return new Date();
359
- }
360
-
361
345
  /**
362
346
  * 現在時刻を timezone での 'yyyy-MM-ddTHH:mm:ss.SSS+HH:mm' 形式の文字列で返す
363
347
  *
@@ -1,46 +0,0 @@
1
- import f from "crypto-js";
2
- const g = {
3
- ascii: "!\"#$%&'()*+,-./0123456789:;<=>?@[]^_`abcdefghijklmnopqrstuvwxyz{|}~",
4
- number: "0123456789",
5
- alphabet: "abcdefghijklmnopqrstuvwxyz",
6
- alphanum: "0123456789abcdefghijklmnopqrstuvwxyz",
7
- hex: "0123456789abcdef"
8
- }, p = (e) => globalThis.crypto.getRandomValues(new Uint8Array(e));
9
- function y(e) {
10
- return f.SHA256(e).toString().toUpperCase();
11
- }
12
- function d(e, r) {
13
- if (!Number.isInteger(e) || e < 0)
14
- throw new Error("crypto-util.generateRandomString: length must be a non-negative integer");
15
- const s = g[r?.charset ?? "ascii"], i = s.toUpperCase();
16
- let n = r?.case === "upperCase" ? i : r?.case === "lowerCase" ? s : s + i;
17
- const o = r?.includeChars;
18
- o && (n += Array.isArray(o) ? o.join("") : o);
19
- const c = r?.excludeChars;
20
- if (c) {
21
- const l = new Set(Array.isArray(c) ? c : Array.from(c));
22
- n = Array.from(n).filter((u) => !l.has(u)).join("");
23
- }
24
- const a = Array.from(new Set(n));
25
- if (!a.length)
26
- throw new Error("crypto-util.generateRandomString: no characters left after applying excludeChars");
27
- const h = Math.floor(256 / a.length) * a.length - 1;
28
- let t = "";
29
- do
30
- for (t = ""; t.length < e; )
31
- for (const l of p(e - t.length))
32
- l <= h && (t += a[l % a.length]);
33
- while (r?.rejectStartsWithZero && t.startsWith("0"));
34
- return t;
35
- }
36
- const b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
37
- __proto__: null,
38
- generateRandomString: d,
39
- toSha256: y
40
- }, Symbol.toStringTag, { value: "Module" }));
41
- export {
42
- b as c,
43
- d as g,
44
- y as t
45
- };
46
- //# sourceMappingURL=crypto-util-DFJqfmuw.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto-util-DFJqfmuw.js","sources":["../src/crypto-util.ts"],"sourcesContent":["import CryptoJS from 'crypto-js';\n\nconst CHARSETS = {\n ascii: `!\"#$%&'()*+,-./0123456789:;<=>?@[]^_\\`abcdefghijklmnopqrstuvwxyz{|}~`,\n number: '0123456789',\n alphabet: 'abcdefghijklmnopqrstuvwxyz',\n alphanum: '0123456789abcdefghijklmnopqrstuvwxyz',\n hex: '0123456789abcdef'\n} as const;\n\nconst randomBytes = (size: number): Uint8Array => globalThis.crypto.getRandomValues(new Uint8Array(size));\n\n/**\n * 文字列をSHA-256でハッシュ化し、大文字の16進数文字列で返す\n *\n * @param {string} str\n * @returns {string}\n */\nexport function toSha256(str: string): string {\n return CryptoJS.SHA256(str).toString().toUpperCase();\n}\n\n/**\n * ランダムな文字列を生成する\n * 大文字と小文字は別の文字として扱う\n * caseを指定しない場合は生成対象の文字セットに大文字と小文字の両方を含めるため、'a'と'A'の出現率は同じ確率になる\n *\n * @param {number} length 生成する文字列の桁数\n * @param {*} [options]\n * ├ charset 'ascii' | 'number' | 'alphabet' | 'alphanum' | 'hex' 未指定の場合はASCIIの記号・数字・英字(スペースとバックスラッシュを除く)\n * ├ case 'upperCase' | 'lowerCase' 英字を大文字のみ・小文字のみにする。未指定の場合は大文字小文字混在\n * ├ rejectStartsWithZero trueを指定した場合、0始まりの文字列を生成しない\n * ├ includeChars 文字セットに追加する文字。大文字小文字を区別する\n * ├ excludeChars 文字セットから除外する文字。大文字小文字は区別する\n * @returns {string}\n */\nexport function generateRandomString(length: number, options?: {\n charset?: 'ascii' | 'number' | 'alphabet' | 'alphanum' | 'hex';\n case?: 'upperCase' | 'lowerCase';\n rejectStartsWithZero?: boolean;\n includeChars?: string | string[];\n excludeChars?: string | string[];\n}): string {\n if (!Number.isInteger(length) || length < 0) {\n throw new Error('crypto-util.generateRandomString: length must be a non-negative integer');\n }\n\n const lower = CHARSETS[options?.charset ?? 'ascii'];\n const upper = lower.toUpperCase();\n let pool = options?.case === 'upperCase'\n ? upper\n : options?.case === 'lowerCase'\n ? lower\n : lower + upper;\n const includeChars = options?.includeChars;\n if (includeChars) {\n // 追加文字の指定がある場合\n pool += Array.isArray(includeChars) ? includeChars.join('') : includeChars;\n }\n const excludeChars = options?.excludeChars;\n if (excludeChars) {\n // 除外文字の指定がある場合\n const excluded = new Set(Array.isArray(excludeChars) ? excludeChars : Array.from(excludeChars));\n pool = Array.from(pool).filter(a => !excluded.has(a)).join('');\n }\n const characters = Array.from(new Set(pool));\n if (!characters.length) {\n throw new Error('crypto-util.generateRandomString: no characters left after applying excludeChars');\n }\n // 256を文字種の数で割り切れる範囲のバイトだけを使い、文字ごとの出現率を揃える\n const maxAcceptableValue = Math.floor(256 / characters.length) * characters.length - 1;\n let result = '';\n do {\n result = '';\n while (result.length < length) {\n for (const byte of randomBytes(length - result.length)) {\n if (byte <= maxAcceptableValue) {\n result += characters[byte % characters.length];\n }\n }\n }\n } while (options?.rejectStartsWithZero && result.startsWith('0'));\n return result;\n}\n"],"names":["CHARSETS","randomBytes","size","toSha256","str","CryptoJS","generateRandomString","length","options","lower","upper","pool","includeChars","excludeChars","excluded","a","characters","maxAcceptableValue","result","byte"],"mappings":";AAEA,MAAMA,IAAW;AAAA,EACf,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,UAAU;AAAA,EACV,KAAK;AACP,GAEMC,IAAc,CAACC,MAA6B,WAAW,OAAO,gBAAgB,IAAI,WAAWA,CAAI,CAAC;AAQjG,SAASC,EAASC,GAAqB;AAC5C,SAAOC,EAAS,OAAOD,CAAG,EAAE,SAAA,EAAW,YAAA;AACzC;AAgBO,SAASE,EAAqBC,GAAgBC,GAM1C;AACT,MAAI,CAAC,OAAO,UAAUD,CAAM,KAAKA,IAAS;AACxC,UAAM,IAAI,MAAM,yEAAyE;AAG3F,QAAME,IAAQT,EAASQ,GAAS,WAAW,OAAO,GAC5CE,IAAQD,EAAM,YAAA;AACpB,MAAIE,IAAOH,GAAS,SAAS,cACzBE,IACAF,GAAS,SAAS,cAChBC,IACAA,IAAQC;AACd,QAAME,IAAeJ,GAAS;AAC9B,EAAII,MAEFD,KAAQ,MAAM,QAAQC,CAAY,IAAIA,EAAa,KAAK,EAAE,IAAIA;AAEhE,QAAMC,IAAeL,GAAS;AAC9B,MAAIK,GAAc;AAEhB,UAAMC,IAAW,IAAI,IAAI,MAAM,QAAQD,CAAY,IAAIA,IAAe,MAAM,KAAKA,CAAY,CAAC;AAC9F,IAAAF,IAAO,MAAM,KAAKA,CAAI,EAAE,OAAO,CAAAI,MAAK,CAACD,EAAS,IAAIC,CAAC,CAAC,EAAE,KAAK,EAAE;AAAA,EAC/D;AACA,QAAMC,IAAa,MAAM,KAAK,IAAI,IAAIL,CAAI,CAAC;AAC3C,MAAI,CAACK,EAAW;AACd,UAAM,IAAI,MAAM,kFAAkF;AAGpG,QAAMC,IAAqB,KAAK,MAAM,MAAMD,EAAW,MAAM,IAAIA,EAAW,SAAS;AACrF,MAAIE,IAAS;AACb;AAEE,SADAA,IAAS,IACFA,EAAO,SAASX;AACrB,iBAAWY,KAAQlB,EAAYM,IAASW,EAAO,MAAM;AACnD,QAAIC,KAAQF,MACVC,KAAUF,EAAWG,IAAOH,EAAW,MAAM;AAAA,SAI5CR,GAAS,wBAAwBU,EAAO,WAAW,GAAG;AAC/D,SAAOA;AACT;;;;;;"}
@@ -1,2 +0,0 @@
1
- "use strict";const y=require("crypto-js"),d={ascii:"!\"#$%&'()*+,-./0123456789:;<=>?@[]^_`abcdefghijklmnopqrstuvwxyz{|}~",number:"0123456789",alphabet:"abcdefghijklmnopqrstuvwxyz",alphanum:"0123456789abcdefghijklmnopqrstuvwxyz",hex:"0123456789abcdef"},p=e=>globalThis.crypto.getRandomValues(new Uint8Array(e));function h(e){return y.SHA256(e).toString().toUpperCase()}function u(e,r){if(!Number.isInteger(e)||e<0)throw new Error("crypto-util.generateRandomString: length must be a non-negative integer");const s=d[r?.charset??"ascii"],i=s.toUpperCase();let n=r?.case==="upperCase"?i:r?.case==="lowerCase"?s:s+i;const o=r?.includeChars;o&&(n+=Array.isArray(o)?o.join(""):o);const c=r?.excludeChars;if(c){const l=new Set(Array.isArray(c)?c:Array.from(c));n=Array.from(n).filter(f=>!l.has(f)).join("")}const a=Array.from(new Set(n));if(!a.length)throw new Error("crypto-util.generateRandomString: no characters left after applying excludeChars");const g=Math.floor(256/a.length)*a.length-1;let t="";do for(t="";t.length<e;)for(const l of p(e-t.length))l<=g&&(t+=a[l%a.length]);while(r?.rejectStartsWithZero&&t.startsWith("0"));return t}const m=Object.freeze(Object.defineProperty({__proto__:null,generateRandomString:u,toSha256:h},Symbol.toStringTag,{value:"Module"}));exports.cryptoUtil=m;exports.generateRandomString=u;exports.toSha256=h;
2
- //# sourceMappingURL=crypto-util-DeZSGetI.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto-util-DeZSGetI.cjs","sources":["../src/crypto-util.ts"],"sourcesContent":["import CryptoJS from 'crypto-js';\n\nconst CHARSETS = {\n ascii: `!\"#$%&'()*+,-./0123456789:;<=>?@[]^_\\`abcdefghijklmnopqrstuvwxyz{|}~`,\n number: '0123456789',\n alphabet: 'abcdefghijklmnopqrstuvwxyz',\n alphanum: '0123456789abcdefghijklmnopqrstuvwxyz',\n hex: '0123456789abcdef'\n} as const;\n\nconst randomBytes = (size: number): Uint8Array => globalThis.crypto.getRandomValues(new Uint8Array(size));\n\n/**\n * 文字列をSHA-256でハッシュ化し、大文字の16進数文字列で返す\n *\n * @param {string} str\n * @returns {string}\n */\nexport function toSha256(str: string): string {\n return CryptoJS.SHA256(str).toString().toUpperCase();\n}\n\n/**\n * ランダムな文字列を生成する\n * 大文字と小文字は別の文字として扱う\n * caseを指定しない場合は生成対象の文字セットに大文字と小文字の両方を含めるため、'a'と'A'の出現率は同じ確率になる\n *\n * @param {number} length 生成する文字列の桁数\n * @param {*} [options]\n * ├ charset 'ascii' | 'number' | 'alphabet' | 'alphanum' | 'hex' 未指定の場合はASCIIの記号・数字・英字(スペースとバックスラッシュを除く)\n * ├ case 'upperCase' | 'lowerCase' 英字を大文字のみ・小文字のみにする。未指定の場合は大文字小文字混在\n * ├ rejectStartsWithZero trueを指定した場合、0始まりの文字列を生成しない\n * ├ includeChars 文字セットに追加する文字。大文字小文字を区別する\n * ├ excludeChars 文字セットから除外する文字。大文字小文字は区別する\n * @returns {string}\n */\nexport function generateRandomString(length: number, options?: {\n charset?: 'ascii' | 'number' | 'alphabet' | 'alphanum' | 'hex';\n case?: 'upperCase' | 'lowerCase';\n rejectStartsWithZero?: boolean;\n includeChars?: string | string[];\n excludeChars?: string | string[];\n}): string {\n if (!Number.isInteger(length) || length < 0) {\n throw new Error('crypto-util.generateRandomString: length must be a non-negative integer');\n }\n\n const lower = CHARSETS[options?.charset ?? 'ascii'];\n const upper = lower.toUpperCase();\n let pool = options?.case === 'upperCase'\n ? upper\n : options?.case === 'lowerCase'\n ? lower\n : lower + upper;\n const includeChars = options?.includeChars;\n if (includeChars) {\n // 追加文字の指定がある場合\n pool += Array.isArray(includeChars) ? includeChars.join('') : includeChars;\n }\n const excludeChars = options?.excludeChars;\n if (excludeChars) {\n // 除外文字の指定がある場合\n const excluded = new Set(Array.isArray(excludeChars) ? excludeChars : Array.from(excludeChars));\n pool = Array.from(pool).filter(a => !excluded.has(a)).join('');\n }\n const characters = Array.from(new Set(pool));\n if (!characters.length) {\n throw new Error('crypto-util.generateRandomString: no characters left after applying excludeChars');\n }\n // 256を文字種の数で割り切れる範囲のバイトだけを使い、文字ごとの出現率を揃える\n const maxAcceptableValue = Math.floor(256 / characters.length) * characters.length - 1;\n let result = '';\n do {\n result = '';\n while (result.length < length) {\n for (const byte of randomBytes(length - result.length)) {\n if (byte <= maxAcceptableValue) {\n result += characters[byte % characters.length];\n }\n }\n }\n } while (options?.rejectStartsWithZero && result.startsWith('0'));\n return result;\n}\n"],"names":["CHARSETS","randomBytes","size","toSha256","str","CryptoJS","generateRandomString","length","options","lower","upper","pool","includeChars","excludeChars","excluded","a","characters","maxAcceptableValue","result","byte"],"mappings":"0CAEMA,EAAW,CACf,MAAO,uEACP,OAAQ,aACR,SAAU,6BACV,SAAU,uCACV,IAAK,kBACP,EAEMC,EAAeC,GAA6B,WAAW,OAAO,gBAAgB,IAAI,WAAWA,CAAI,CAAC,EAQjG,SAASC,EAASC,EAAqB,CAC5C,OAAOC,EAAS,OAAOD,CAAG,EAAE,SAAA,EAAW,YAAA,CACzC,CAgBO,SAASE,EAAqBC,EAAgBC,EAM1C,CACT,GAAI,CAAC,OAAO,UAAUD,CAAM,GAAKA,EAAS,EACxC,MAAM,IAAI,MAAM,yEAAyE,EAG3F,MAAME,EAAQT,EAASQ,GAAS,SAAW,OAAO,EAC5CE,EAAQD,EAAM,YAAA,EACpB,IAAIE,EAAOH,GAAS,OAAS,YACzBE,EACAF,GAAS,OAAS,YAChBC,EACAA,EAAQC,EACd,MAAME,EAAeJ,GAAS,aAC1BI,IAEFD,GAAQ,MAAM,QAAQC,CAAY,EAAIA,EAAa,KAAK,EAAE,EAAIA,GAEhE,MAAMC,EAAeL,GAAS,aAC9B,GAAIK,EAAc,CAEhB,MAAMC,EAAW,IAAI,IAAI,MAAM,QAAQD,CAAY,EAAIA,EAAe,MAAM,KAAKA,CAAY,CAAC,EAC9FF,EAAO,MAAM,KAAKA,CAAI,EAAE,OAAOI,GAAK,CAACD,EAAS,IAAIC,CAAC,CAAC,EAAE,KAAK,EAAE,CAC/D,CACA,MAAMC,EAAa,MAAM,KAAK,IAAI,IAAIL,CAAI,CAAC,EAC3C,GAAI,CAACK,EAAW,OACd,MAAM,IAAI,MAAM,kFAAkF,EAGpG,MAAMC,EAAqB,KAAK,MAAM,IAAMD,EAAW,MAAM,EAAIA,EAAW,OAAS,EACrF,IAAIE,EAAS,GACb,EAEE,KADAA,EAAS,GACFA,EAAO,OAASX,GACrB,UAAWY,KAAQlB,EAAYM,EAASW,EAAO,MAAM,EAC/CC,GAAQF,IACVC,GAAUF,EAAWG,EAAOH,EAAW,MAAM,SAI5CR,GAAS,sBAAwBU,EAAO,WAAW,GAAG,GAC/D,OAAOA,CACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-util-CG7L8nSP.js","sources":["../src/date-util.ts"],"sourcesContent":["import { DateTime, Duration as LuxonDuration } from 'luxon';\nimport type { DateTimeUnit } from 'luxon';\n\n/** 日時として解釈する値。string はISO形式または inputFormat の書式、number は epoch ミリ秒 */\nexport type DateInput = string | Date | number | null | undefined;\n\n/** 日時の切り捨て(startOf / endOf)に使う単位 */\nexport type DateUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';\n\n/** 期間の単位 */\nexport type TimeUnit = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years';\n\n/** 日時の加算・減算に使う期間。負の値で減算になる */\nexport interface Duration {\n years?: number;\n quarters?: number;\n months?: number;\n weeks?: number;\n days?: number;\n hours?: number;\n minutes?: number;\n seconds?: number;\n milliseconds?: number;\n}\n\n/**\n * 日時を解釈するときのオプション\n */\nexport interface ParseDateOptions {\n /** 入力の書式。配列の場合は先頭から順に試す。いずれにも一致しない場合はISO形式として解釈する */\n inputFormat?: string | string[];\n /** ゾーン情報を含まない入力をどのタイムゾーンの日時とみなすか(IANA名)。既定は 'UTC' */\n inputTimezone?: string;\n /** 解釈した日時に加算する期間。startOf / endOf より先に適用する */\n duration?: Duration;\n /** 指定した単位の最初の時点に切り捨てる(month なら月初の00:00:00.000) */\n startOf?: DateUnit;\n /** 指定した単位の最後の時点に切り上げる(month なら月末の23:59:59.999) */\n endOf?: DateUnit;\n}\n\n/**\n * 日時を文字列にするときのオプション\n */\nexport interface FormatDateOptions extends ParseDateOptions {\n /** 出力の書式。省略時はISO形式 */\n outputFormat?: string;\n /** 出力に使うタイムゾーン(IANA名)。既定は 'UTC' */\n outputTimezone?: string;\n /** 日時として解釈できない値に対する出力。既定は 'Invalid Date' */\n invalidText?: string;\n}\n\n/** タイムゾーンの略称。夏時間のないタイムゾーンでは daylight を持たない */\nexport interface TimezoneAbbreviation {\n standard: string;\n daylight?: string;\n}\n\n/** IANA名をキーにしたタイムゾーンの略称の表 */\nexport type TimezoneAbbreviations = Record<string, TimezoneAbbreviation>;\n\n/**\n * タイムゾーンの略称を解決するときのオプション\n */\nexport interface TimezoneAbbrOptions {\n /** 夏時間かどうかを判定する時点。既定は現在時刻 */\n at?: Date;\n /** 既定の表に追加・上書きする略称 */\n abbreviations?: TimezoneAbbreviations;\n}\n\nconst DEFAULT_TIMEZONE = 'UTC';\n\nconst TIMESTAMP_FORMAT = `yyyy-MM-dd'T'HH:mm:ss.SSSZZ`;\n\n/** 1970-01-01 を表すExcelの日付シリアル値 */\nconst EXCEL_EPOCH_SERIAL = 25569;\n\nconst MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;\n\nconst MILLISECONDS_PER_HOUR = 60 * 60 * 1000;\n\nconst GMT_OFFSET = /GMT[+-]\\d{1,2}(:\\d{2})?/g;\n\n/**\n * 略称の既定の表。略称は世界で一意ではないため(CST は米国中部・中国などで使われる)、このライブラリが採用する表記である\n */\nconst DEFAULT_TIMEZONE_ABBREVIATIONS: TimezoneAbbreviations = {\n 'UTC': { standard: 'UTC' },\n 'Asia/Tokyo': { standard: 'JST' },\n 'Asia/Seoul': { standard: 'KST' },\n 'Asia/Shanghai': { standard: 'CST' },\n 'Asia/Hong_Kong': { standard: 'HKT' },\n 'Asia/Taipei': { standard: 'CST' },\n 'Asia/Singapore': { standard: 'SGT' },\n 'Asia/Manila': { standard: 'PHT' },\n 'Asia/Bangkok': { standard: 'ICT' },\n 'Asia/Ho_Chi_Minh': { standard: 'ICT' },\n 'Asia/Jakarta': { standard: 'WIB' },\n 'Asia/Kolkata': { standard: 'IST' },\n 'Asia/Dubai': { standard: 'GST' },\n 'Australia/Sydney': { standard: 'AEST', daylight: 'AEDT' },\n 'Pacific/Auckland': { standard: 'NZST', daylight: 'NZDT' },\n 'Europe/London': { standard: 'GMT', daylight: 'BST' },\n 'Europe/Paris': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Berlin': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Madrid': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Rome': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Amsterdam': { standard: 'CET', daylight: 'CEST' },\n 'America/New_York': { standard: 'EST', daylight: 'EDT' },\n 'America/Toronto': { standard: 'EST', daylight: 'EDT' },\n 'America/Chicago': { standard: 'CST', daylight: 'CDT' },\n 'America/Denver': { standard: 'MST', daylight: 'MDT' },\n 'America/Phoenix': { standard: 'MST' },\n 'America/Los_Angeles': { standard: 'PST', daylight: 'PDT' },\n 'America/Vancouver': { standard: 'PST', daylight: 'PDT' },\n 'America/Mexico_City': { standard: 'CST' },\n 'America/Sao_Paulo': { standard: 'BRT' }\n};\n\n/**\n * タイムゾーンの指定が不正な場合は、日時の不正とは区別して例外にする\n */\nconst assertZone = (d: DateTime): void => {\n if (!d.isValid && d.invalidReason === 'unsupported zone') {\n throw new RangeError(d.invalidExplanation ?? d.invalidReason);\n }\n};\n\nconst toDateTime = (value: DateInput, options?: ParseDateOptions): DateTime | null => {\n if (value == null || value === '') {\n return null;\n }\n const zone = options?.inputTimezone ?? DEFAULT_TIMEZONE;\n let d: DateTime | null = null;\n if (value instanceof Date) {\n d = DateTime.fromJSDate(value, { zone: zone });\n } else if (typeof value === 'number') {\n d = Number.isFinite(value) ? DateTime.fromMillis(value, { zone: zone }) : null;\n } else {\n const formats = options?.inputFormat ? [options.inputFormat].flat() : [];\n for (const format of formats) {\n const parsed = DateTime.fromFormat(value, format, { zone: zone });\n assertZone(parsed);\n if (parsed.isValid) {\n d = parsed;\n break;\n }\n }\n if (d == null) {\n d = DateTime.fromISO(value, { zone: zone });\n }\n }\n if (d == null) {\n return null;\n }\n assertZone(d);\n if (!d.isValid) {\n return null;\n }\n if (options?.duration) {\n d = d.plus(options.duration);\n }\n if (options?.startOf) {\n d = d.startOf(options.startOf);\n }\n if (options?.endOf) {\n d = d.endOf(options.endOf);\n }\n return d;\n};\n\nconst compare = (date1: DateInput, date2: DateInput, options: ParseDateOptions | undefined, predicate: (v1: number, v2: number) => boolean): boolean => {\n const d1 = toDateTime(date1, options);\n const d2 = toDateTime(date2, options);\n if (!d1 || !d2) {\n return false;\n }\n return predicate(d1.valueOf(), d2.valueOf());\n};\n\n/**\n * 値を日時として解釈し、Date を返す\n * duration / startOf / endOf は inputTimezone のゾーンで計算する\n * 解釈できない値、null / undefined / 空文字は null を返す。タイムゾーンの指定が不正な場合は RangeError をスローする\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {Date | null}\n */\nexport function parseDate(value: DateInput, options?: ParseDateOptions): Date | null {\n return toDateTime(value, options)?.toJSDate() ?? null;\n}\n\n/**\n * 値を日時として解釈し、outputTimezone での文字列にする\n * null / undefined / 空文字は空文字を返す。解釈できない値は invalidText(既定 'Invalid Date')を返す\n * タイムゾーンの指定が不正な場合は RangeError をスローする\n *\n * @param {DateInput} value\n * @param {FormatDateOptions} [options]\n * @returns {string}\n */\nexport function formatDate(value: DateInput, options?: FormatDateOptions): string {\n if (value == null || value === '') {\n return '';\n }\n const d = toDateTime(value, options);\n if (!d) {\n return options?.invalidText ?? 'Invalid Date';\n }\n const output = d.setZone(options?.outputTimezone ?? DEFAULT_TIMEZONE);\n assertZone(output);\n return options?.outputFormat ? output.toFormat(options.outputFormat) : output.toISO() as string;\n}\n\n/**\n * 値が日時として解釈できるか判定する\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isValid(value: DateInput, options?: ParseDateOptions): boolean {\n return toDateTime(value, options) != null;\n}\n\n/**\n * date1 と date2 が同じ時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSame(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 === v2);\n}\n\n/**\n * date1 が date2 より前の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isBefore(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 < v2);\n}\n\n/**\n * date1 が date2 と同じか、より前の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSameOrBefore(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 <= v2);\n}\n\n/**\n * date1 が date2 より後の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isAfter(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v2 < v1);\n}\n\n/**\n * date1 が date2 と同じか、より後の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSameOrAfter(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v2 <= v1);\n}\n\n/**\n * 値が inputTimezone での今日より前の日付か判定する。解釈できない場合は false\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isPastDate(value: DateInput, options?: ParseDateOptions): boolean {\n const target = toDateTime(value, options)?.startOf('day');\n if (!target) {\n return false;\n }\n const today = DateTime.now().setZone(options?.inputTimezone ?? DEFAULT_TIMEZONE).startOf('day');\n return target.valueOf() < today.valueOf();\n}\n\n/**\n * 値が現在時刻より前か判定する。解釈できない場合は false\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isPastDateTime(value: DateInput, options?: ParseDateOptions): boolean {\n const target = toDateTime(value, options);\n return target != null && target.valueOf() < Date.now();\n}\n\n/**\n * date1 − date2 を unit の単位で返す\n * 両方を inputTimezone で unit の始まりに切り捨ててから差を取るため、暦の上での差になる(23:00 と翌 01:00 の days は 1)\n * どちらかが解釈できない場合は NaN を返す\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {TimeUnit} unit\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {number}\n */\nexport function diff(date1: DateInput, date2: DateInput, unit: TimeUnit, options?: ParseDateOptions): number {\n const d1 = toDateTime(date1, options);\n const d2 = toDateTime(date2, options);\n if (!d1 || !d2) {\n return NaN;\n }\n // 'days' → 'day' のように切り捨ての単位にする\n const dateUnit = unit.slice(0, -1) as DateTimeUnit;\n return d1.startOf(dateUnit).diff(d2.startOf(dateUnit), unit).get(unit);\n}\n\n/**\n * timezone での今日の始まりを返す\n *\n * @param {string} [timezone] IANA名。既定は 'UTC'\n * @returns {Date}\n */\nexport function currentDate(timezone: string = DEFAULT_TIMEZONE): Date {\n const d = DateTime.now().setZone(timezone).startOf('day');\n assertZone(d);\n return d.toJSDate();\n}\n\n/**\n * 現在時刻を返す\n * Date はタイムゾーンを保持しないため、ゾーンは文字列にする時点(formatDate の outputTimezone)で指定する\n *\n * @returns {Date}\n */\nexport function currentDateTime(): Date {\n return new Date();\n}\n\n/**\n * 現在時刻を timezone での 'yyyy-MM-ddTHH:mm:ss.SSS+HH:mm' 形式の文字列で返す\n *\n * @param {string} [timezone] IANA名。既定は 'UTC'\n * @returns {string}\n */\nexport function currentTimestamp(timezone: string = DEFAULT_TIMEZONE): string {\n const d = DateTime.now().setZone(timezone);\n assertZone(d);\n return d.toFormat(TIMESTAMP_FORMAT);\n}\n\n/**\n * Excelの日付シリアル値を epoch ミリ秒に変換する\n * Excelの日付シリアル値はゾーンの概念を持たないため、そのままではUTCの日時として変換される\n * シリアル値がどのゾーンの日時かが分かっている場合は offset に時間差を指定する\n *\n * @example\n * convertExcelDateSerialToUnixTimeSerial(45200); // 1696118400000 (2023-10-01T00:00:00Z)\n * convertExcelDateSerialToUnixTimeSerial(45200, { offset: 9 }); // 1696086000000 (2023-10-01T00:00:00+09:00)\n *\n * @param {number} excelDateSerial\n * @param {*} [options]\n * └ offset シリアル値のゾーンのUTCからの時間差(時)\n * @returns {number}\n */\nexport function convertExcelDateSerialToUnixTimeSerial(excelDateSerial: number, options?: {\n offset: number;\n}): number {\n let timeserial = (excelDateSerial - EXCEL_EPOCH_SERIAL) * MILLISECONDS_PER_DAY;\n if (options?.offset) {\n timeserial -= options.offset * MILLISECONDS_PER_HOUR;\n }\n return timeserial;\n}\n\n/**\n * 期間の値を別の単位に換算する\n * 月と年は固定長(1か月 = 30日、1年 = 365日)として換算する\n *\n * @example\n * convertTimeUnit(1, 'hours', 'milliseconds'); // 3600000\n *\n * @param {number} value\n * @param {TimeUnit} inputUnit\n * @param {TimeUnit} outputUnit\n * @returns {number}\n */\nexport function convertTimeUnit(value: number, inputUnit: TimeUnit, outputUnit: TimeUnit): number {\n return LuxonDuration.fromObject({ [inputUnit]: value }).as(outputUnit);\n}\n\n/**\n * タイムゾーンの略称を返す。夏時間の期間中は夏時間の略称を返す\n * 既定の表にない場合は null を返す。表は options.abbreviations で追加・上書きできる\n *\n * @param {string} timezone IANA名\n * @param {TimezoneAbbrOptions} [options]\n * @returns {string | null}\n */\nexport function getTimezoneAbbr(timezone: string, options?: TimezoneAbbrOptions): string | null {\n const definition = { ...DEFAULT_TIMEZONE_ABBREVIATIONS, ...options?.abbreviations }[timezone];\n if (!definition) {\n return null;\n }\n if (definition.daylight) {\n const d = DateTime.fromJSDate(options?.at ?? new Date(), { zone: timezone });\n assertZone(d);\n if (d.isInDST) {\n return definition.daylight;\n }\n }\n return definition.standard;\n}\n\n/**\n * 文字列中の 'GMT+9' のようなオフセット表記を、timezone の略称に置き換える\n * 略称が解決できない場合は文字列をそのまま返す\n *\n * @param {string} text\n * @param {string} timezone IANA名\n * @param {TimezoneAbbrOptions} [options]\n * @returns {string}\n */\nexport function applyTimezoneAbbr(text: string, timezone: string, options?: TimezoneAbbrOptions): string {\n const abbr = getTimezoneAbbr(timezone, options);\n return abbr == null ? text : text.replace(GMT_OFFSET, abbr);\n}\n"],"names":["DEFAULT_TIMEZONE","TIMESTAMP_FORMAT","EXCEL_EPOCH_SERIAL","MILLISECONDS_PER_DAY","MILLISECONDS_PER_HOUR","GMT_OFFSET","DEFAULT_TIMEZONE_ABBREVIATIONS","assertZone","d","toDateTime","value","options","zone","DateTime","formats","format","parsed","compare","date1","date2","predicate","d1","d2","parseDate","formatDate","output","isValid","isSame","v1","v2","isBefore","isSameOrBefore","isAfter","isSameOrAfter","isPastDate","target","today","isPastDateTime","diff","unit","dateUnit","currentDate","timezone","currentDateTime","currentTimestamp","convertExcelDateSerialToUnixTimeSerial","excelDateSerial","timeserial","convertTimeUnit","inputUnit","outputUnit","LuxonDuration","getTimezoneAbbr","definition","applyTimezoneAbbr","text","abbr"],"mappings":";AAwEA,MAAMA,IAAmB,OAEnBC,IAAmB,+BAGnBC,IAAqB,OAErBC,IAAuB,OAAU,KAAK,KAEtCC,IAAwB,OAAU,KAElCC,IAAa,4BAKbC,IAAwD;AAAA,EAC5D,KAAO,EAAE,UAAU,MAAA;AAAA,EACnB,cAAc,EAAE,UAAU,MAAA;AAAA,EAC1B,cAAc,EAAE,UAAU,MAAA;AAAA,EAC1B,iBAAiB,EAAE,UAAU,MAAA;AAAA,EAC7B,kBAAkB,EAAE,UAAU,MAAA;AAAA,EAC9B,eAAe,EAAE,UAAU,MAAA;AAAA,EAC3B,kBAAkB,EAAE,UAAU,MAAA;AAAA,EAC9B,eAAe,EAAE,UAAU,MAAA;AAAA,EAC3B,gBAAgB,EAAE,UAAU,MAAA;AAAA,EAC5B,oBAAoB,EAAE,UAAU,MAAA;AAAA,EAChC,gBAAgB,EAAE,UAAU,MAAA;AAAA,EAC5B,gBAAgB,EAAE,UAAU,MAAA;AAAA,EAC5B,cAAc,EAAE,UAAU,MAAA;AAAA,EAC1B,oBAAoB,EAAE,UAAU,QAAQ,UAAU,OAAA;AAAA,EAClD,oBAAoB,EAAE,UAAU,QAAQ,UAAU,OAAA;AAAA,EAClD,iBAAiB,EAAE,UAAU,OAAO,U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AOD,IAAOA,EAAK,QAAQlD,GAAYmD,CAAI;AAC5D;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,2 +0,0 @@
1
- "use strict";const i=require("luxon"),f="UTC",F="yyyy-MM-dd'T'HH:mm:ss.SSSZZ",U=25569,B=1440*60*1e3,N=3600*1e3,R=/GMT[+-]\d{1,2}(:\d{2})?/g,Z={UTC:{standard:"UTC"},"Asia/Tokyo":{standard:"JST"},"Asia/Seoul":{standard:"KST"},"Asia/Shanghai":{standard:"CST"},"Asia/Hong_Kong":{standard:"HKT"},"Asia/Taipei":{standard:"CST"},"Asia/Singapore":{standard:"SGT"},"Asia/Manila":{standard:"PHT"},"Asia/Bangkok":{standard:"ICT"},"Asia/Ho_Chi_Minh":{standard:"ICT"},"Asia/Jakarta":{standard:"WIB"},"Asia/Kolkata":{standard:"IST"},"Asia/Dubai":{standard:"GST"},"Australia/Sydney":{standard:"AEST",daylight:"AEDT"},"Pacific/Auckland":{standard:"NZST",daylight:"NZDT"},"Europe/London":{standard:"GMT",daylight:"BST"},"Europe/Paris":{standard:"CET",daylight:"CEST"},"Europe/Berlin":{standard:"CET",daylight:"CEST"},"Europe/Madrid":{standard:"CET",daylight:"CEST"},"Europe/Rome":{standard:"CET",daylight:"CEST"},"Europe/Amsterdam":{standard:"CET",daylight:"CEST"},"America/New_York":{standard:"EST",daylight:"EDT"},"America/Toronto":{standard:"EST",daylight:"EDT"},"America/Chicago":{standard:"CST",daylight:"CDT"},"America/Denver":{standard:"MST",daylight:"MDT"},"America/Phoenix":{standard:"MST"},"America/Los_Angeles":{standard:"PST",daylight:"PDT"},"America/Vancouver":{standard:"PST",daylight:"PDT"},"America/Mexico_City":{standard:"CST"},"America/Sao_Paulo":{standard:"BRT"}},u=t=>{if(!t.isValid&&t.invalidReason==="unsupported zone")throw new RangeError(t.invalidExplanation??t.invalidReason)},s=(t,a)=>{if(t==null||t==="")return null;const e=a?.inputTimezone??f;let n=null;if(t instanceof Date)n=i.DateTime.fromJSDate(t,{zone:e});else if(typeof t=="number")n=Number.isFinite(t)?i.DateTime.fromMillis(t,{zone:e}):null;else{const r=a?.inputFormat?[a.inputFormat].flat():[];for(const o of r){const d=i.DateTime.fromFormat(t,o,{zone:e});if(u(d),d.isValid){n=d;break}}n==null&&(n=i.DateTime.fromISO(t,{zone:e}))}return n==null||(u(n),!n.isValid)?null:(a?.duration&&(n=n.plus(a.duration)),a?.startOf&&(n=n.startOf(a.startOf)),a?.endOf&&(n=n.endOf(a.endOf)),n)},T=(t,a,e,n)=>{const r=s(t,e),o=s(a,e);return!r||!o?!1:n(r.valueOf(),o.valueOf())};function c(t,a){return s(t,a)?.toJSDate()??null}function m(t,a){if(t==null||t==="")return"";const e=s(t,a);if(!e)return a?.invalidText??"Invalid Date";const n=e.setZone(a?.outputTimezone??f);return u(n),a?.outputFormat?n.toFormat(a.outputFormat):n.toISO()}function S(t,a){return s(t,a)!=null}function D(t,a,e){return T(t,a,e,(n,r)=>n===r)}function A(t,a,e){return T(t,a,e,(n,r)=>n<r)}function E(t,a,e){return T(t,a,e,(n,r)=>n<=r)}function O(t,a,e){return T(t,a,e,(n,r)=>r<n)}function y(t,a,e){return T(t,a,e,(n,r)=>r<=n)}function g(t,a){const e=s(t,a)?.startOf("day");if(!e)return!1;const n=i.DateTime.now().setZone(a?.inputTimezone??f).startOf("day");return e.valueOf()<n.valueOf()}function C(t,a){const e=s(t,a);return e!=null&&e.valueOf()<Date.now()}function h(t,a,e,n){const r=s(t,n),o=s(a,n);if(!r||!o)return NaN;const d=e.slice(0,-1);return r.startOf(d).diff(o.startOf(d),e).get(e)}function _(t=f){const a=i.DateTime.now().setZone(t).startOf("day");return u(a),a.toJSDate()}function M(){return new Date}function b(t=f){const a=i.DateTime.now().setZone(t);return u(a),a.toFormat(F)}function I(t,a){let e=(t-U)*B;return a?.offset&&(e-=a.offset*N),e}function P(t,a,e){return i.Duration.fromObject({[a]:t}).as(e)}function l(t,a){const e={...Z,...a?.abbreviations}[t];if(!e)return null;if(e.daylight){const n=i.DateTime.fromJSDate(a?.at??new Date,{zone:t});if(u(n),n.isInDST)return e.daylight}return e.standard}function p(t,a,e){const n=l(a,e);return n==null?t:t.replace(R,n)}const z=Object.freeze(Object.defineProperty({__proto__:null,applyTimezoneAbbr:p,convertExcelDateSerialToUnixTimeSerial:I,convertTimeUnit:P,currentDate:_,currentDateTime:M,currentTimestamp:b,diff:h,formatDate:m,getTimezoneAbbr:l,isAfter:O,isBefore:A,isPastDate:g,isPastDateTime:C,isSame:D,isSameOrAfter:y,isSameOrBefore:E,isValid:S,parseDate:c},Symbol.toStringTag,{value:"Module"}));exports.applyTimezoneAbbr=p;exports.convertExcelDateSerialToUnixTimeSerial=I;exports.convertTimeUnit=P;exports.currentDate=_;exports.currentDateTime=M;exports.currentTimestamp=b;exports.dateUtil=z;exports.diff=h;exports.formatDate=m;exports.getTimezoneAbbr=l;exports.isAfter=O;exports.isBefore=A;exports.isPastDate=g;exports.isPastDateTime=C;exports.isSame=D;exports.isSameOrAfter=y;exports.isSameOrBefore=E;exports.isValid=S;exports.parseDate=c;
2
- //# sourceMappingURL=date-util-DopNKy3u.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"date-util-DopNKy3u.cjs","sources":["../src/date-util.ts"],"sourcesContent":["import { DateTime, Duration as LuxonDuration } from 'luxon';\nimport type { DateTimeUnit } from 'luxon';\n\n/** 日時として解釈する値。string はISO形式または inputFormat の書式、number は epoch ミリ秒 */\nexport type DateInput = string | Date | number | null | undefined;\n\n/** 日時の切り捨て(startOf / endOf)に使う単位 */\nexport type DateUnit = 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';\n\n/** 期間の単位 */\nexport type TimeUnit = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years';\n\n/** 日時の加算・減算に使う期間。負の値で減算になる */\nexport interface Duration {\n years?: number;\n quarters?: number;\n months?: number;\n weeks?: number;\n days?: number;\n hours?: number;\n minutes?: number;\n seconds?: number;\n milliseconds?: number;\n}\n\n/**\n * 日時を解釈するときのオプション\n */\nexport interface ParseDateOptions {\n /** 入力の書式。配列の場合は先頭から順に試す。いずれにも一致しない場合はISO形式として解釈する */\n inputFormat?: string | string[];\n /** ゾーン情報を含まない入力をどのタイムゾーンの日時とみなすか(IANA名)。既定は 'UTC' */\n inputTimezone?: string;\n /** 解釈した日時に加算する期間。startOf / endOf より先に適用する */\n duration?: Duration;\n /** 指定した単位の最初の時点に切り捨てる(month なら月初の00:00:00.000) */\n startOf?: DateUnit;\n /** 指定した単位の最後の時点に切り上げる(month なら月末の23:59:59.999) */\n endOf?: DateUnit;\n}\n\n/**\n * 日時を文字列にするときのオプション\n */\nexport interface FormatDateOptions extends ParseDateOptions {\n /** 出力の書式。省略時はISO形式 */\n outputFormat?: string;\n /** 出力に使うタイムゾーン(IANA名)。既定は 'UTC' */\n outputTimezone?: string;\n /** 日時として解釈できない値に対する出力。既定は 'Invalid Date' */\n invalidText?: string;\n}\n\n/** タイムゾーンの略称。夏時間のないタイムゾーンでは daylight を持たない */\nexport interface TimezoneAbbreviation {\n standard: string;\n daylight?: string;\n}\n\n/** IANA名をキーにしたタイムゾーンの略称の表 */\nexport type TimezoneAbbreviations = Record<string, TimezoneAbbreviation>;\n\n/**\n * タイムゾーンの略称を解決するときのオプション\n */\nexport interface TimezoneAbbrOptions {\n /** 夏時間かどうかを判定する時点。既定は現在時刻 */\n at?: Date;\n /** 既定の表に追加・上書きする略称 */\n abbreviations?: TimezoneAbbreviations;\n}\n\nconst DEFAULT_TIMEZONE = 'UTC';\n\nconst TIMESTAMP_FORMAT = `yyyy-MM-dd'T'HH:mm:ss.SSSZZ`;\n\n/** 1970-01-01 を表すExcelの日付シリアル値 */\nconst EXCEL_EPOCH_SERIAL = 25569;\n\nconst MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;\n\nconst MILLISECONDS_PER_HOUR = 60 * 60 * 1000;\n\nconst GMT_OFFSET = /GMT[+-]\\d{1,2}(:\\d{2})?/g;\n\n/**\n * 略称の既定の表。略称は世界で一意ではないため(CST は米国中部・中国などで使われる)、このライブラリが採用する表記である\n */\nconst DEFAULT_TIMEZONE_ABBREVIATIONS: TimezoneAbbreviations = {\n 'UTC': { standard: 'UTC' },\n 'Asia/Tokyo': { standard: 'JST' },\n 'Asia/Seoul': { standard: 'KST' },\n 'Asia/Shanghai': { standard: 'CST' },\n 'Asia/Hong_Kong': { standard: 'HKT' },\n 'Asia/Taipei': { standard: 'CST' },\n 'Asia/Singapore': { standard: 'SGT' },\n 'Asia/Manila': { standard: 'PHT' },\n 'Asia/Bangkok': { standard: 'ICT' },\n 'Asia/Ho_Chi_Minh': { standard: 'ICT' },\n 'Asia/Jakarta': { standard: 'WIB' },\n 'Asia/Kolkata': { standard: 'IST' },\n 'Asia/Dubai': { standard: 'GST' },\n 'Australia/Sydney': { standard: 'AEST', daylight: 'AEDT' },\n 'Pacific/Auckland': { standard: 'NZST', daylight: 'NZDT' },\n 'Europe/London': { standard: 'GMT', daylight: 'BST' },\n 'Europe/Paris': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Berlin': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Madrid': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Rome': { standard: 'CET', daylight: 'CEST' },\n 'Europe/Amsterdam': { standard: 'CET', daylight: 'CEST' },\n 'America/New_York': { standard: 'EST', daylight: 'EDT' },\n 'America/Toronto': { standard: 'EST', daylight: 'EDT' },\n 'America/Chicago': { standard: 'CST', daylight: 'CDT' },\n 'America/Denver': { standard: 'MST', daylight: 'MDT' },\n 'America/Phoenix': { standard: 'MST' },\n 'America/Los_Angeles': { standard: 'PST', daylight: 'PDT' },\n 'America/Vancouver': { standard: 'PST', daylight: 'PDT' },\n 'America/Mexico_City': { standard: 'CST' },\n 'America/Sao_Paulo': { standard: 'BRT' }\n};\n\n/**\n * タイムゾーンの指定が不正な場合は、日時の不正とは区別して例外にする\n */\nconst assertZone = (d: DateTime): void => {\n if (!d.isValid && d.invalidReason === 'unsupported zone') {\n throw new RangeError(d.invalidExplanation ?? d.invalidReason);\n }\n};\n\nconst toDateTime = (value: DateInput, options?: ParseDateOptions): DateTime | null => {\n if (value == null || value === '') {\n return null;\n }\n const zone = options?.inputTimezone ?? DEFAULT_TIMEZONE;\n let d: DateTime | null = null;\n if (value instanceof Date) {\n d = DateTime.fromJSDate(value, { zone: zone });\n } else if (typeof value === 'number') {\n d = Number.isFinite(value) ? DateTime.fromMillis(value, { zone: zone }) : null;\n } else {\n const formats = options?.inputFormat ? [options.inputFormat].flat() : [];\n for (const format of formats) {\n const parsed = DateTime.fromFormat(value, format, { zone: zone });\n assertZone(parsed);\n if (parsed.isValid) {\n d = parsed;\n break;\n }\n }\n if (d == null) {\n d = DateTime.fromISO(value, { zone: zone });\n }\n }\n if (d == null) {\n return null;\n }\n assertZone(d);\n if (!d.isValid) {\n return null;\n }\n if (options?.duration) {\n d = d.plus(options.duration);\n }\n if (options?.startOf) {\n d = d.startOf(options.startOf);\n }\n if (options?.endOf) {\n d = d.endOf(options.endOf);\n }\n return d;\n};\n\nconst compare = (date1: DateInput, date2: DateInput, options: ParseDateOptions | undefined, predicate: (v1: number, v2: number) => boolean): boolean => {\n const d1 = toDateTime(date1, options);\n const d2 = toDateTime(date2, options);\n if (!d1 || !d2) {\n return false;\n }\n return predicate(d1.valueOf(), d2.valueOf());\n};\n\n/**\n * 値を日時として解釈し、Date を返す\n * duration / startOf / endOf は inputTimezone のゾーンで計算する\n * 解釈できない値、null / undefined / 空文字は null を返す。タイムゾーンの指定が不正な場合は RangeError をスローする\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {Date | null}\n */\nexport function parseDate(value: DateInput, options?: ParseDateOptions): Date | null {\n return toDateTime(value, options)?.toJSDate() ?? null;\n}\n\n/**\n * 値を日時として解釈し、outputTimezone での文字列にする\n * null / undefined / 空文字は空文字を返す。解釈できない値は invalidText(既定 'Invalid Date')を返す\n * タイムゾーンの指定が不正な場合は RangeError をスローする\n *\n * @param {DateInput} value\n * @param {FormatDateOptions} [options]\n * @returns {string}\n */\nexport function formatDate(value: DateInput, options?: FormatDateOptions): string {\n if (value == null || value === '') {\n return '';\n }\n const d = toDateTime(value, options);\n if (!d) {\n return options?.invalidText ?? 'Invalid Date';\n }\n const output = d.setZone(options?.outputTimezone ?? DEFAULT_TIMEZONE);\n assertZone(output);\n return options?.outputFormat ? output.toFormat(options.outputFormat) : output.toISO() as string;\n}\n\n/**\n * 値が日時として解釈できるか判定する\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isValid(value: DateInput, options?: ParseDateOptions): boolean {\n return toDateTime(value, options) != null;\n}\n\n/**\n * date1 と date2 が同じ時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSame(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 === v2);\n}\n\n/**\n * date1 が date2 より前の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isBefore(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 < v2);\n}\n\n/**\n * date1 が date2 と同じか、より前の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSameOrBefore(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v1 <= v2);\n}\n\n/**\n * date1 が date2 より後の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isAfter(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v2 < v1);\n}\n\n/**\n * date1 が date2 と同じか、より後の時刻か判定する。どちらかが解釈できない場合は false\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {boolean}\n */\nexport function isSameOrAfter(date1: DateInput, date2: DateInput, options?: ParseDateOptions): boolean {\n return compare(date1, date2, options, (v1, v2) => v2 <= v1);\n}\n\n/**\n * 値が inputTimezone での今日より前の日付か判定する。解釈できない場合は false\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isPastDate(value: DateInput, options?: ParseDateOptions): boolean {\n const target = toDateTime(value, options)?.startOf('day');\n if (!target) {\n return false;\n }\n const today = DateTime.now().setZone(options?.inputTimezone ?? DEFAULT_TIMEZONE).startOf('day');\n return target.valueOf() < today.valueOf();\n}\n\n/**\n * 値が現在時刻より前か判定する。解釈できない場合は false\n *\n * @param {DateInput} value\n * @param {ParseDateOptions} [options]\n * @returns {boolean}\n */\nexport function isPastDateTime(value: DateInput, options?: ParseDateOptions): boolean {\n const target = toDateTime(value, options);\n return target != null && target.valueOf() < Date.now();\n}\n\n/**\n * date1 − date2 を unit の単位で返す\n * 両方を inputTimezone で unit の始まりに切り捨ててから差を取るため、暦の上での差になる(23:00 と翌 01:00 の days は 1)\n * どちらかが解釈できない場合は NaN を返す\n *\n * @param {DateInput} date1\n * @param {DateInput} date2\n * @param {TimeUnit} unit\n * @param {ParseDateOptions} [options] 両方の値に適用する\n * @returns {number}\n */\nexport function diff(date1: DateInput, date2: DateInput, unit: TimeUnit, options?: ParseDateOptions): number {\n const d1 = toDateTime(date1, options);\n const d2 = toDateTime(date2, options);\n if (!d1 || !d2) {\n return NaN;\n }\n // 'days' → 'day' のように切り捨ての単位にする\n const dateUnit = unit.slice(0, -1) as DateTimeUnit;\n return d1.startOf(dateUnit).diff(d2.startOf(dateUnit), unit).get(unit);\n}\n\n/**\n * timezone での今日の始まりを返す\n *\n * @param {string} [timezone] IANA名。既定は 'UTC'\n * @returns {Date}\n */\nexport function currentDate(timezone: string = DEFAULT_TIMEZONE): Date {\n const d = DateTime.now().setZone(timezone).startOf('day');\n assertZone(d);\n return d.toJSDate();\n}\n\n/**\n * 現在時刻を返す\n * Date はタイムゾーンを保持しないため、ゾーンは文字列にする時点(formatDate の outputTimezone)で指定する\n *\n * @returns {Date}\n */\nexport function currentDateTime(): Date {\n return new Date();\n}\n\n/**\n * 現在時刻を timezone での 'yyyy-MM-ddTHH:mm:ss.SSS+HH:mm' 形式の文字列で返す\n *\n * @param {string} [timezone] IANA名。既定は 'UTC'\n * @returns {string}\n */\nexport function currentTimestamp(timezone: string = DEFAULT_TIMEZONE): string {\n const d = DateTime.now().setZone(timezone);\n assertZone(d);\n return d.toFormat(TIMESTAMP_FORMAT);\n}\n\n/**\n * Excelの日付シリアル値を epoch ミリ秒に変換する\n * Excelの日付シリアル値はゾーンの概念を持たないため、そのままではUTCの日時として変換される\n * シリアル値がどのゾーンの日時かが分かっている場合は offset に時間差を指定する\n *\n * @example\n * convertExcelDateSerialToUnixTimeSerial(45200); // 1696118400000 (2023-10-01T00:00:00Z)\n * convertExcelDateSerialToUnixTimeSerial(45200, { offset: 9 }); // 1696086000000 (2023-10-01T00:00:00+09:00)\n *\n * @param {number} excelDateSerial\n * @param {*} [options]\n * └ offset シリアル値のゾーンのUTCからの時間差(時)\n * @returns {number}\n */\nexport function convertExcelDateSerialToUnixTimeSerial(excelDateSerial: number, options?: {\n offset: number;\n}): number {\n let timeserial = (excelDateSerial - EXCEL_EPOCH_SERIAL) * MILLISECONDS_PER_DAY;\n if (options?.offset) {\n timeserial -= options.offset * MILLISECONDS_PER_HOUR;\n }\n return timeserial;\n}\n\n/**\n * 期間の値を別の単位に換算する\n * 月と年は固定長(1か月 = 30日、1年 = 365日)として換算する\n *\n * @example\n * convertTimeUnit(1, 'hours', 'milliseconds'); // 3600000\n *\n * @param {number} value\n * @param {TimeUnit} inputUnit\n * @param {TimeUnit} outputUnit\n * @returns {number}\n */\nexport function convertTimeUnit(value: number, inputUnit: TimeUnit, outputUnit: TimeUnit): number {\n return LuxonDuration.fromObject({ [inputUnit]: value }).as(outputUnit);\n}\n\n/**\n * タイムゾーンの略称を返す。夏時間の期間中は夏時間の略称を返す\n * 既定の表にない場合は null を返す。表は options.abbreviations で追加・上書きできる\n *\n * @param {string} timezone IANA名\n * @param {TimezoneAbbrOptions} [options]\n * @returns {string | null}\n */\nexport function getTimezoneAbbr(timezone: string, options?: TimezoneAbbrOptions): string | null {\n const definition = { ...DEFAULT_TIMEZONE_ABBREVIATIONS, ...options?.abbreviations }[timezone];\n if (!definition) {\n return null;\n }\n if (definition.daylight) {\n const d = DateTime.fromJSDate(options?.at ?? new Date(), { zone: timezone });\n assertZone(d);\n if (d.isInDST) {\n return definition.daylight;\n }\n }\n return definition.standard;\n}\n\n/**\n * 文字列中の 'GMT+9' のようなオフセット表記を、timezone の略称に置き換える\n * 略称が解決できない場合は文字列をそのまま返す\n *\n * @param {string} text\n * @param {string} timezone IANA名\n * @param {TimezoneAbbrOptions} [options]\n * @returns {string}\n */\nexport function applyTimezoneAbbr(text: string, timezone: string, options?: TimezoneAbbrOptions): string {\n const abbr = getTimezoneAbbr(timezone, options);\n return abbr == null ? text : text.replace(GMT_OFFSET, abbr);\n}\n"],"names":["DEFAULT_TIMEZONE","TIMESTAMP_FORMAT","EXCEL_EPOCH_SERIAL","MILLISECONDS_PER_DAY","MILLISECONDS_PER_HOUR","GMT_OFFSET","DEFAULT_TIMEZONE_ABBREVIATIONS","assertZone","d","toDateTime","value","options","zone","DateTime","formats","format","parsed","compare","date1","date2","predicate","d1","d2","parseDate","formatDate","output","isValid","isSame","v1","v2","isBefore","isSameOrBefore","isAfter","isSameOrAfter","isPastDate","target","today","isPastDateTime","diff","unit","dateUnit","currentDate","timezone","currentDateTime","currentTimestamp","convertExcelDateSerialToUnixTimeSerial","excelDateSerial","timeserial","convertTimeUnit","inputUnit","outputUnit","LuxonDuration","getTimezoneAbbr","definition","applyTimezoneAbbr","text","abbr"],"mappings":"sCAwEMA,EAAmB,MAEnBC,EAAmB,8BAGnBC,EAAqB,MAErBC,EAAuB,KAAU,GAAK,IAEtCC,EAAwB,KAAU,IAElCC,EAAa,2BAKbC,EAAwD,CAC5D,IAAO,CAAE,SAAU,KAAA,EACnB,aAAc,CAAE,SAAU,KAAA,EAC1B,aAAc,CAAE,SAAU,KAAA,EAC1B,gBAAiB,CAAE,SAAU,KAAA,EAC7B,iBAAkB,CAAE,SAAU,KAAA,EAC9B,cAAe,CAAE,SAAU,KAAA,EAC3B,iBAAkB,CAAE,SAAU,KAAA,EAC9B,cAAe,CAAE,SAAU,KAAA,EAC3B,eAAgB,CAAE,SAAU,KAAA,EAC5B,mBAAoB,CAAE,SAAU,KAAA,EAChC,eAAgB,CAAE,SAAU,KAAA,EAC5B,eAAgB,CAAE,SAAU,KAAA,EAC5B,aAAc,CAAE,SAAU,KAAA,EAC1B,mBAAoB,CAAE,SAAU,OAAQ,SAAU,MAAA,EAClD,mBAAoB,CAAE,SAAU,OAAQ,SAAU,MAAA,EAClD,gBAAiB,CAAE,SAAU,MAAO,SAAU,KAAA,EAC9C,eAAgB,CAAE,SAAU,MAAO,SAAU,MAAA,EAC7C,gBAAiB,CAAE,SAAU,MAAO,SAAU,MAAA,EAC9C,gBAAiB,CAAE,SAAU,MAAO,SAAU,MAAA,EAC9C,cAAe,CAAE,SAAU,MAAO,SAAU,MAAA,EAC5C,mBAAoB,CAAE,SAAU,MAAO,SAAU,MAAA,EACjD,mBAAoB,CAAE,SAAU,MAAO,SAAU,KAAA,EACjD,kBAAmB,CAAE,SAAU,MAAO,SAAU,KAAA,EAChD,kBAAmB,CAAE,SAAU,MAAO,SAAU,KAAA,EAChD,iBAAkB,CAAE,SAAU,MAA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