chronos-date 1.0.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.
- package/LICENSE +201 -0
- package/README.md +31 -0
- package/dist/basic-CKxaRSHQ.cjs +1 -0
- package/dist/basic-e46DaNAi.mjs +1 -0
- package/dist/constants.cjs +1 -0
- package/dist/constants.d.cts +2 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.mjs +1 -0
- package/dist/convert-Bmp63ats.mjs +1 -0
- package/dist/convert-DrLrcgqz.cjs +1 -0
- package/dist/greet-BBsrvmkn.mjs +1 -0
- package/dist/greet-C-6mruI9.cjs +1 -0
- package/dist/guards.cjs +1 -0
- package/dist/guards.d.cts +71 -0
- package/dist/guards.d.mts +71 -0
- package/dist/guards.mjs +1 -0
- package/dist/helpers-DGzYnP81.cjs +1 -0
- package/dist/helpers-N1X_Rj_V.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -0
- package/dist/non-primitives-B2EE6D6s.mjs +1 -0
- package/dist/non-primitives-Bu3a4WL4.cjs +1 -0
- package/dist/plugins/banglaPlugin.cjs +1 -0
- package/dist/plugins/banglaPlugin.d.cts +225 -0
- package/dist/plugins/banglaPlugin.d.mts +225 -0
- package/dist/plugins/banglaPlugin.mjs +1 -0
- package/dist/plugins/businessPlugin.cjs +1 -0
- package/dist/plugins/businessPlugin.d.cts +446 -0
- package/dist/plugins/businessPlugin.d.mts +446 -0
- package/dist/plugins/businessPlugin.mjs +1 -0
- package/dist/plugins/dateRangePlugin.cjs +1 -0
- package/dist/plugins/dateRangePlugin.d.cts +71 -0
- package/dist/plugins/dateRangePlugin.d.mts +71 -0
- package/dist/plugins/dateRangePlugin.mjs +1 -0
- package/dist/plugins/dayPartPlugin.cjs +1 -0
- package/dist/plugins/dayPartPlugin.d.cts +45 -0
- package/dist/plugins/dayPartPlugin.d.mts +45 -0
- package/dist/plugins/dayPartPlugin.mjs +1 -0
- package/dist/plugins/durationPlugin.cjs +1 -0
- package/dist/plugins/durationPlugin.d.cts +30 -0
- package/dist/plugins/durationPlugin.d.mts +30 -0
- package/dist/plugins/durationPlugin.mjs +1 -0
- package/dist/plugins/fromNowPlugin.cjs +1 -0
- package/dist/plugins/fromNowPlugin.d.cts +24 -0
- package/dist/plugins/fromNowPlugin.d.mts +24 -0
- package/dist/plugins/fromNowPlugin.mjs +1 -0
- package/dist/plugins/greetingPlugin.cjs +1 -0
- package/dist/plugins/greetingPlugin.d.cts +29 -0
- package/dist/plugins/greetingPlugin.d.mts +29 -0
- package/dist/plugins/greetingPlugin.mjs +1 -0
- package/dist/plugins/palindromePlugin.cjs +1 -0
- package/dist/plugins/palindromePlugin.d.cts +38 -0
- package/dist/plugins/palindromePlugin.d.mts +38 -0
- package/dist/plugins/palindromePlugin.mjs +1 -0
- package/dist/plugins/relativeTimePlugin.cjs +1 -0
- package/dist/plugins/relativeTimePlugin.d.cts +82 -0
- package/dist/plugins/relativeTimePlugin.d.mts +82 -0
- package/dist/plugins/relativeTimePlugin.mjs +1 -0
- package/dist/plugins/roundPlugin.cjs +1 -0
- package/dist/plugins/roundPlugin.d.cts +29 -0
- package/dist/plugins/roundPlugin.d.mts +29 -0
- package/dist/plugins/roundPlugin.mjs +1 -0
- package/dist/plugins/seasonPlugin.cjs +1 -0
- package/dist/plugins/seasonPlugin.d.cts +26 -0
- package/dist/plugins/seasonPlugin.d.mts +26 -0
- package/dist/plugins/seasonPlugin.mjs +1 -0
- package/dist/plugins/timeZonePlugin.cjs +1 -0
- package/dist/plugins/timeZonePlugin.d.cts +88 -0
- package/dist/plugins/timeZonePlugin.d.mts +88 -0
- package/dist/plugins/timeZonePlugin.mjs +1 -0
- package/dist/plugins/zodiacPlugin.cjs +1 -0
- package/dist/plugins/zodiacPlugin.d.cts +41 -0
- package/dist/plugins/zodiacPlugin.d.mts +41 -0
- package/dist/plugins/zodiacPlugin.mjs +1 -0
- package/dist/primitives-Cxss_JVF.mjs +1 -0
- package/dist/primitives-Db2FUp4e.cjs +1 -0
- package/dist/seasons-ChAIVphi.mjs +1 -0
- package/dist/seasons-CioTH5Dm.d.mts +5285 -0
- package/dist/seasons-CsVeJ27s.d.cts +5285 -0
- package/dist/seasons-oABOhHcX.cjs +1 -0
- package/dist/timezone-B10UItNO.mjs +1 -0
- package/dist/timezone-CWxbK_7I.cjs +1 -0
- package/dist/types-B2fgrJ86.d.mts +2123 -0
- package/dist/types-DPTQ_yLx.d.cts +2123 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +2 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/dist/utilities-B8dOAQVD.cjs +1 -0
- package/dist/utilities-BJE06bms.mjs +1 -0
- package/dist/utilities-D2-p26DX.cjs +1 -0
- package/dist/utilities-DV_ohS37.mjs +1 -0
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.cts +188 -0
- package/dist/utils.d.mts +188 -0
- package/dist/utils.mjs +1 -0
- package/package.json +162 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { C as $Chronos, m as SeasonOptions } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/seasonPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns the current season name based on optional season rules or presets.
|
|
8
|
+
* @param options Configuration with optional custom seasons or preset name.
|
|
9
|
+
* @returns The name of the season the current date falls under.
|
|
10
|
+
*/
|
|
11
|
+
season(options?: SeasonOptions): string;
|
|
12
|
+
/**
|
|
13
|
+
* @instance Returns the current season name based on optional season rules or presets.
|
|
14
|
+
*
|
|
15
|
+
* @remarks This method is an alias for {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/names#season season} method.
|
|
16
|
+
*
|
|
17
|
+
* @param options Configuration with optional custom seasons or preset name.
|
|
18
|
+
* @returns The name of the season the current date falls under.
|
|
19
|
+
*/
|
|
20
|
+
getSeasonName(options?: SeasonOptions): string;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** * Plugin to inject `season`/`getSeasonName` method */
|
|
24
|
+
declare const seasonPlugin: ($Chronos: $Chronos) => void;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { seasonPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as e}from"../seasons-ChAIVphi.mjs";const t=t=>{t.prototype.season=function(t){let{preset:n=`default`}=t??{},r=t?.seasons??e[n],i=this.format(`MM-DD`);for(let{name:e,boundary:t}of r)if(`startDate`in t&&`endDate`in t){let n=t.startDate,r=t.endDate;if(n<=r){if(i>=n&&i<=r)return e}else if(i>=n||i<=r)return e}else if(`startMonth`in t&&`endMonth`in t){let{startMonth:n,endMonth:r}=t;if(n<=r){if(this.month>=n&&this.month<=r)return e}else if(this.month>=n||this.month<=r)return e}return`Unknown`},t.prototype.getSeasonName=function(e){return this.season(e)}};export{t as seasonPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=require(`../timezone-CWxbK_7I.cjs`),n=require(`../guards.cjs`),r=require(`../helpers-DGzYnP81.cjs`),i=require(`../utilities-B8dOAQVD.cjs`),a=a=>{let{internalDate:o,withOrigin:s,offset:c}=a[e.s],l=e=>e===`UTC+00:00`||e===`UTC-00:00`,u=e=>e?e in t.o:!1,d=e=>e in t.r,f=e=>{if(u(e))return t.o[e]},p=(e,t)=>{let n=[`long`,`longOffset`],i={tzId:e};for(let a of n){let n=a===`long`?`tzName`:`offset`;try{let o=r.p(e,a,t);i[n]=a===`longOffset`?r.s(o):o}catch{i[n]=void 0}}return i},m=new Map(t.n.reduce((e,t)=>{let{offset:n}=p(t);if(n){let r=e.get(n)??[];r.push(t),e.set(n,r)}return e},new Map)),h=new Map(Object.entries(t.r).map(([e,{offset:t,tzName:n}])=>[t,{tzAbbr:e,tzName:n}])),g=e=>{let t=m.get(e);if(!(!t||t?.length===0))return t?.length===1?t[0]:t},_=(e,r)=>{if(l(e))return`Greenwich Mean Time`;if(n.isValidUTCOffset(e)){let t=f(e);return!t&&h.has(e)?h.get(e)?.tzName:t}else if(d(e))return t.r[e].tzName;else{let{offset:t,tzName:n}=p(e,r);return n||f(t)}};a.prototype.timeZone=function(e){let r,c;n.isValidUTCOffset(e)?(r=e,c=g(r)||r):d(e)?(r=t.r[e].offset,c=g(r)||r):(r=p(e,o(this)).offset||t.r.UTC.offset,c=e);let l=e||r,u=_(l,o(this))??r,f=i.r(r)-this.getTimeZoneOffsetMinutes();return s(new a(new Date(o(this).getTime()+f*60*1e3)),`timeZone`,r,u,c,l)},a.prototype.getTimeZoneName=function(e){let t=e||c(this);return _(e||this?.$tzTracker||c(this),o(this))??t};let v=new Map,y=e=>e.split(/\s+/).map(e=>e[0]).join(``).replace(/\W/g,``);a.prototype.getTimeZoneNameShort=function(e){let t=this?.$tzTracker,r=e||c(this),i=e||t||c(this);if(l(i))return`GMT`;if(!e&&t&&d(t))return t;if(n.isValidUTCOffset(i)){if(v.has(i))return v.get(i);if(h.has(i))return h.get(i)?.tzAbbr;let e=f(i);if(e){let t=y(e);return v.set(i,t),t}}let a=_(i,o(this))??r;if(v.has(`name-${a}`))return v.get(a);let s=n.isValidUTCOffset(a)?a:y(a);return v.set(`name-${a}`,s),s},a.prototype.getTimeZoneNameAbbr=function(e){return this.getTimeZoneNameShort(e)}};exports.timeZonePlugin=a;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { C as $Chronos, En as LooseLiteral, Nt as TimeZoneIdentifier, Pt as TimeZoneName, Rt as UTCOffset, kt as TimeZone } from "../types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/timeZonePlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Creates a new instance of `Chronos` for the specified time zone identifier.
|
|
8
|
+
*
|
|
9
|
+
* @remarks Using time zone identifier to create time zone instance is the best option as it extracts info from {@link Intl.supportedValuesOf} API.
|
|
10
|
+
*
|
|
11
|
+
* @param tzId - Time zone identifier (e.g., `'Africa/Harare'`). See: {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database on Wikipedia}.
|
|
12
|
+
* @returns A new instance of `Chronos` with time in the given time zone identifier. Invalid input sets time-zone to `UTC`.
|
|
13
|
+
*/
|
|
14
|
+
timeZone(tzId: TimeZoneIdentifier): Chronos;
|
|
15
|
+
/**
|
|
16
|
+
* @instance Creates a new instance of `Chronos` for the specified abbreviated time zone name.
|
|
17
|
+
*
|
|
18
|
+
* @remarks Use abbreviated time zone name to create time zone instance only when you can't figure out the time zone identifier {@link TimeZoneIdentifier}.
|
|
19
|
+
*
|
|
20
|
+
* @param zone - Standard time zone abbreviation (e.g., `'IST'`, `'UTC'`, `'EST'` etc.). See: {@link https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations Time zone abbreviations on Wikipedia}.
|
|
21
|
+
* @returns A new instance of `Chronos` with time in the given time zone abbreviation. Invalid input sets time-zone to `UTC`.
|
|
22
|
+
*/
|
|
23
|
+
timeZone(zone: TimeZone): Chronos;
|
|
24
|
+
/**
|
|
25
|
+
* @instance Creates a new instance of `Chronos` for the specified UTC offset.
|
|
26
|
+
*
|
|
27
|
+
* @remarks Use UTC offset only to create a fictional/unlisted time zone instance.
|
|
28
|
+
*
|
|
29
|
+
* @param utc - UTC Offset in `UTC±HH:mm` format for fictional or unlisted time zone (e.g., `'UTC+06:15'`).
|
|
30
|
+
* @returns A new instance of `Chronos` with time in the given utc offset. Invalid input sets time-zone to `UTC`.
|
|
31
|
+
*/
|
|
32
|
+
timeZone(utc: UTCOffset): Chronos;
|
|
33
|
+
/**
|
|
34
|
+
* @instance Creates a new instance of `Chronos` for the specified time zone id, abbreviation or UTC offset.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* - Using time zone identifier to create time zone instance is the best option as it extracts info from {@link Intl.supportedValuesOf} API.
|
|
38
|
+
* - Use abbreviated time zone name to create time zone instance only when you can't figure out the time zone identifier.
|
|
39
|
+
* - Use UTC offset only to create a fictional/unlisted time zone instance.
|
|
40
|
+
*
|
|
41
|
+
* @param tz - A time zone identifier ({@link TimeZoneIdentifier}), time zone abbreviation ({@link TimeZone}), or UTC offset ({@link UTCOffset}).
|
|
42
|
+
* @returns A new instance of `Chronos` with time in the given parameter. Invalid input sets time zone to `UTC`.
|
|
43
|
+
*/
|
|
44
|
+
timeZone(tz: TimeZoneIdentifier | TimeZone | UTCOffset): Chronos;
|
|
45
|
+
/**
|
|
46
|
+
* @instance Returns the current time zone name as a full descriptive string (e.g. `"Bangladesh Standard Time"`).
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* - This method uses a predefined mapping of UTC offsets to time zone names.
|
|
50
|
+
* - If multiple time zones share the same UTC offset, it returns the **first match** from the predefined list.
|
|
51
|
+
* - If no match is found (which is rare), it falls back to returning the UTC offset (e.g. `"UTC+06:00"`).
|
|
52
|
+
* - To retrieve the local system's native time zone name (or its identifier if the name is unavailable), use the {@link $getNativeTimeZoneName} instance method.
|
|
53
|
+
* - To retrieve the local system's native time zone identifier, use the {@link $getNativeTimeZoneId} instance method.
|
|
54
|
+
*
|
|
55
|
+
* @param utc Optional UTC offset in `"UTC+06:00"` format. When passed, it bypasses the current time zone offset.
|
|
56
|
+
* @returns Time zone name in full descriptive string or UTC offset if it is not a valid time zone.
|
|
57
|
+
*/
|
|
58
|
+
getTimeZoneName(utc?: UTCOffset): LooseLiteral<TimeZoneName | UTCOffset>;
|
|
59
|
+
/**
|
|
60
|
+
* @instance Returns the current time zone abbreviation (e.g. `"BST"` for `Bangladesh Standard Time`).
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* - This method uses a predefined mapping of UTC offsets to abbreviated time zone codes.
|
|
64
|
+
* - If multiple time zones share the same UTC offset, it returns the **first abbreviation** from the list.
|
|
65
|
+
* - If no abbreviation is found it abbreviates full time zone name from {@link TIME_ZONE_LABELS} using UTC offset.
|
|
66
|
+
* - If no match is found (for unlisted or fictional utc offset), it returns the UTC offset (e.g. `"UTC+06:00"`).
|
|
67
|
+
* - To retrieve the local system's native time zone name (or its identifier if the name is unavailable), use the {@link $getNativeTimeZoneName} instance method.
|
|
68
|
+
* - To retrieve the local system's native time zone identifier, use the {@link $getNativeTimeZoneId} instance method.
|
|
69
|
+
*
|
|
70
|
+
* @param utc Optional UTC offset in `"UTC+06:00"` format. When passed, it bypasses the current time zone offset.
|
|
71
|
+
* @returns Time zone name in full descriptive string or UTC offset if it is not a valid time zone.
|
|
72
|
+
*/
|
|
73
|
+
getTimeZoneNameShort(utc?: UTCOffset): LooseLiteral<TimeZone | UTCOffset>;
|
|
74
|
+
/**
|
|
75
|
+
* @instance Returns the current time zone abbreviation (e.g. `"BST"` for `Bangladesh Standard Time`).
|
|
76
|
+
*
|
|
77
|
+
* @remarks This method is an alias for {@link getTimeZoneNameShort}.
|
|
78
|
+
*
|
|
79
|
+
* @param utc Optional UTC offset in `"UTC+06:00"` format. When passed, it bypasses the current time zone offset.
|
|
80
|
+
* @returns Time zone name in full descriptive string or UTC offset if it is not a valid time zone.
|
|
81
|
+
*/
|
|
82
|
+
getTimeZoneNameAbbr(utc?: UTCOffset): LooseLiteral<TimeZone | UTCOffset>;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** * Plugin to inject `timeZone` related methods */
|
|
86
|
+
declare const timeZonePlugin: ($Chronos: $Chronos) => void;
|
|
87
|
+
//#endregion
|
|
88
|
+
export { timeZonePlugin };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { C as $Chronos, En as LooseLiteral, Nt as TimeZoneIdentifier, Pt as TimeZoneName, Rt as UTCOffset, kt as TimeZone } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/timeZonePlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Creates a new instance of `Chronos` for the specified time zone identifier.
|
|
8
|
+
*
|
|
9
|
+
* @remarks Using time zone identifier to create time zone instance is the best option as it extracts info from {@link Intl.supportedValuesOf} API.
|
|
10
|
+
*
|
|
11
|
+
* @param tzId - Time zone identifier (e.g., `'Africa/Harare'`). See: {@link https://en.wikipedia.org/wiki/List_of_tz_database_time_zones IANA TZ Database on Wikipedia}.
|
|
12
|
+
* @returns A new instance of `Chronos` with time in the given time zone identifier. Invalid input sets time-zone to `UTC`.
|
|
13
|
+
*/
|
|
14
|
+
timeZone(tzId: TimeZoneIdentifier): Chronos;
|
|
15
|
+
/**
|
|
16
|
+
* @instance Creates a new instance of `Chronos` for the specified abbreviated time zone name.
|
|
17
|
+
*
|
|
18
|
+
* @remarks Use abbreviated time zone name to create time zone instance only when you can't figure out the time zone identifier {@link TimeZoneIdentifier}.
|
|
19
|
+
*
|
|
20
|
+
* @param zone - Standard time zone abbreviation (e.g., `'IST'`, `'UTC'`, `'EST'` etc.). See: {@link https://en.wikipedia.org/wiki/List_of_time_zone_abbreviations Time zone abbreviations on Wikipedia}.
|
|
21
|
+
* @returns A new instance of `Chronos` with time in the given time zone abbreviation. Invalid input sets time-zone to `UTC`.
|
|
22
|
+
*/
|
|
23
|
+
timeZone(zone: TimeZone): Chronos;
|
|
24
|
+
/**
|
|
25
|
+
* @instance Creates a new instance of `Chronos` for the specified UTC offset.
|
|
26
|
+
*
|
|
27
|
+
* @remarks Use UTC offset only to create a fictional/unlisted time zone instance.
|
|
28
|
+
*
|
|
29
|
+
* @param utc - UTC Offset in `UTC±HH:mm` format for fictional or unlisted time zone (e.g., `'UTC+06:15'`).
|
|
30
|
+
* @returns A new instance of `Chronos` with time in the given utc offset. Invalid input sets time-zone to `UTC`.
|
|
31
|
+
*/
|
|
32
|
+
timeZone(utc: UTCOffset): Chronos;
|
|
33
|
+
/**
|
|
34
|
+
* @instance Creates a new instance of `Chronos` for the specified time zone id, abbreviation or UTC offset.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* - Using time zone identifier to create time zone instance is the best option as it extracts info from {@link Intl.supportedValuesOf} API.
|
|
38
|
+
* - Use abbreviated time zone name to create time zone instance only when you can't figure out the time zone identifier.
|
|
39
|
+
* - Use UTC offset only to create a fictional/unlisted time zone instance.
|
|
40
|
+
*
|
|
41
|
+
* @param tz - A time zone identifier ({@link TimeZoneIdentifier}), time zone abbreviation ({@link TimeZone}), or UTC offset ({@link UTCOffset}).
|
|
42
|
+
* @returns A new instance of `Chronos` with time in the given parameter. Invalid input sets time zone to `UTC`.
|
|
43
|
+
*/
|
|
44
|
+
timeZone(tz: TimeZoneIdentifier | TimeZone | UTCOffset): Chronos;
|
|
45
|
+
/**
|
|
46
|
+
* @instance Returns the current time zone name as a full descriptive string (e.g. `"Bangladesh Standard Time"`).
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* - This method uses a predefined mapping of UTC offsets to time zone names.
|
|
50
|
+
* - If multiple time zones share the same UTC offset, it returns the **first match** from the predefined list.
|
|
51
|
+
* - If no match is found (which is rare), it falls back to returning the UTC offset (e.g. `"UTC+06:00"`).
|
|
52
|
+
* - To retrieve the local system's native time zone name (or its identifier if the name is unavailable), use the {@link $getNativeTimeZoneName} instance method.
|
|
53
|
+
* - To retrieve the local system's native time zone identifier, use the {@link $getNativeTimeZoneId} instance method.
|
|
54
|
+
*
|
|
55
|
+
* @param utc Optional UTC offset in `"UTC+06:00"` format. When passed, it bypasses the current time zone offset.
|
|
56
|
+
* @returns Time zone name in full descriptive string or UTC offset if it is not a valid time zone.
|
|
57
|
+
*/
|
|
58
|
+
getTimeZoneName(utc?: UTCOffset): LooseLiteral<TimeZoneName | UTCOffset>;
|
|
59
|
+
/**
|
|
60
|
+
* @instance Returns the current time zone abbreviation (e.g. `"BST"` for `Bangladesh Standard Time`).
|
|
61
|
+
*
|
|
62
|
+
* @remarks
|
|
63
|
+
* - This method uses a predefined mapping of UTC offsets to abbreviated time zone codes.
|
|
64
|
+
* - If multiple time zones share the same UTC offset, it returns the **first abbreviation** from the list.
|
|
65
|
+
* - If no abbreviation is found it abbreviates full time zone name from {@link TIME_ZONE_LABELS} using UTC offset.
|
|
66
|
+
* - If no match is found (for unlisted or fictional utc offset), it returns the UTC offset (e.g. `"UTC+06:00"`).
|
|
67
|
+
* - To retrieve the local system's native time zone name (or its identifier if the name is unavailable), use the {@link $getNativeTimeZoneName} instance method.
|
|
68
|
+
* - To retrieve the local system's native time zone identifier, use the {@link $getNativeTimeZoneId} instance method.
|
|
69
|
+
*
|
|
70
|
+
* @param utc Optional UTC offset in `"UTC+06:00"` format. When passed, it bypasses the current time zone offset.
|
|
71
|
+
* @returns Time zone name in full descriptive string or UTC offset if it is not a valid time zone.
|
|
72
|
+
*/
|
|
73
|
+
getTimeZoneNameShort(utc?: UTCOffset): LooseLiteral<TimeZone | UTCOffset>;
|
|
74
|
+
/**
|
|
75
|
+
* @instance Returns the current time zone abbreviation (e.g. `"BST"` for `Bangladesh Standard Time`).
|
|
76
|
+
*
|
|
77
|
+
* @remarks This method is an alias for {@link getTimeZoneNameShort}.
|
|
78
|
+
*
|
|
79
|
+
* @param utc Optional UTC offset in `"UTC+06:00"` format. When passed, it bypasses the current time zone offset.
|
|
80
|
+
* @returns Time zone name in full descriptive string or UTC offset if it is not a valid time zone.
|
|
81
|
+
*/
|
|
82
|
+
getTimeZoneNameAbbr(utc?: UTCOffset): LooseLiteral<TimeZone | UTCOffset>;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** * Plugin to inject `timeZone` related methods */
|
|
86
|
+
declare const timeZonePlugin: ($Chronos: $Chronos) => void;
|
|
87
|
+
//#endregion
|
|
88
|
+
export { timeZonePlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as e}from"../basic-e46DaNAi.mjs";import{n as t,o as n,r}from"../timezone-B10UItNO.mjs";import{isValidUTCOffset as i}from"../guards.mjs";import{p as a,s as o}from"../helpers-N1X_Rj_V.mjs";import{r as s}from"../utilities-DV_ohS37.mjs";const c=c=>{let{internalDate:l,withOrigin:u,offset:d}=c[e],f=e=>e===`UTC+00:00`||e===`UTC-00:00`,p=e=>e?e in n:!1,m=e=>e in r,h=e=>{if(p(e))return n[e]},g=(e,t)=>{let n=[`long`,`longOffset`],r={tzId:e};for(let i of n){let n=i===`long`?`tzName`:`offset`;try{let s=a(e,i,t);r[n]=i===`longOffset`?o(s):s}catch{r[n]=void 0}}return r},_=new Map(t.reduce((e,t)=>{let{offset:n}=g(t);if(n){let r=e.get(n)??[];r.push(t),e.set(n,r)}return e},new Map)),v=new Map(Object.entries(r).map(([e,{offset:t,tzName:n}])=>[t,{tzAbbr:e,tzName:n}])),y=e=>{let t=_.get(e);if(!(!t||t?.length===0))return t?.length===1?t[0]:t},b=(e,t)=>{if(f(e))return`Greenwich Mean Time`;if(i(e)){let t=h(e);return!t&&v.has(e)?v.get(e)?.tzName:t}else if(m(e))return r[e].tzName;else{let{offset:n,tzName:r}=g(e,t);return r||h(n)}};c.prototype.timeZone=function(e){let t,n;i(e)?(t=e,n=y(t)||t):m(e)?(t=r[e].offset,n=y(t)||t):(t=g(e,l(this)).offset||r.UTC.offset,n=e);let a=e||t,o=b(a,l(this))??t,d=s(t)-this.getTimeZoneOffsetMinutes();return u(new c(new Date(l(this).getTime()+d*60*1e3)),`timeZone`,t,o,n,a)},c.prototype.getTimeZoneName=function(e){let t=e||d(this);return b(e||this?.$tzTracker||d(this),l(this))??t};let x=new Map,S=e=>e.split(/\s+/).map(e=>e[0]).join(``).replace(/\W/g,``);c.prototype.getTimeZoneNameShort=function(e){let t=this?.$tzTracker,n=e||d(this),r=e||t||d(this);if(f(r))return`GMT`;if(!e&&t&&m(t))return t;if(i(r)){if(x.has(r))return x.get(r);if(v.has(r))return v.get(r)?.tzAbbr;let e=h(r);if(e){let t=S(e);return x.set(r,t),t}}let a=b(r,l(this))??n;if(x.has(`name-${a}`))return x.get(a);let o=i(a)?a:S(a);return x.set(`name-${a}`,o),o},c.prototype.getTimeZoneNameAbbr=function(e){return this.getTimeZoneNameShort(e)}};export{c as timeZonePlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../basic-CKxaRSHQ.cjs`),t=require(`../helpers-DGzYnP81.cjs`),n=n=>{function r(e){return e[0]*100+e[1]}function i(t){let{preset:n=`western`,custom:i}=t??{};return[...i??e.m[n]].sort((e,t)=>r(e[1])-r(t[1]))}n.prototype.getZodiacSign=function(e){let{birthDate:t}=e??{},n,r;t&&t?.includes(`-`)?[n,r]=t.split(`-`).map(Number):(n=this.isoMonth,r=this.date);let a=i(e);for(let e=a.length-1;e>=0;e--){let[t,[i,o]]=a[e];if(n>i||n===i&&r>=o)return t;if(e===0)return a.at(-1)[0]}return a[0][0]},n.prototype.zodiac=function(e){return this.getZodiacSign(e)},n.prototype.getZodiacMeta=function(e,n){let r=i(n),a=r.findIndex(([t])=>t===e);if(a===-1)throw RangeError(`Invalid zodiac sign: "${e}"`);let[o,s]=r[a][1],[c,l]=(r[a+1]??r[0])[1];return{index:a,sign:e,start:`${t.f(o)}-${t.f(s)}`,end:`${t.f(c)}-${t.f(l-1)}`}}};exports.zodiacPlugin=n;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { C as $Chronos, S as ZodiacSign, b as ZodiacOptions, v as ZodiacMeta, y as ZodiacMetaOptions } from "../types-DPTQ_yLx.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/zodiacPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns the zodiac sign based on current date or `birthDate` option.
|
|
8
|
+
* @param options Optional config to choose preset or provide custom zodiac date ranges.
|
|
9
|
+
* @returns The matching zodiac sign from preset/custom list.
|
|
10
|
+
*/
|
|
11
|
+
getZodiacSign<Sign extends string = ZodiacSign>(options?: ZodiacOptions<Sign>): Sign;
|
|
12
|
+
/**
|
|
13
|
+
* @instance Returns the zodiac sign based on current date or `birthDate` option.
|
|
14
|
+
* @remarks This method is an alias for {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/names#getzodiacsign getZodiacSign} method.
|
|
15
|
+
*
|
|
16
|
+
* @param options Optional config to choose preset or provide custom zodiac date ranges.
|
|
17
|
+
* @returns The matching zodiac sign from preset/custom list.
|
|
18
|
+
*/
|
|
19
|
+
zodiac<Sign extends string = ZodiacSign>(options?: ZodiacOptions<Sign>): Sign;
|
|
20
|
+
/**
|
|
21
|
+
* @instance Returns detailed metadata for a given zodiac sign based on the selected `preset` or custom ranges.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - The metadata includes the sign's `index` within the normalized zodiac order, its inclusive start and end dates.
|
|
25
|
+
* - **Note:** The returned `index` represents the chronological position of the zodiac sign based on Gregorian month–day ordering and may vary between different zodiac variants.
|
|
26
|
+
* - Handles year-boundary wrapping correctly (e.g. Capricorn, Sagittarius).
|
|
27
|
+
*
|
|
28
|
+
* @param sign The zodiac sign to retrieve metadata for.
|
|
29
|
+
* @param options Optional configuration to select a zodiac preset or provide custom ranges.
|
|
30
|
+
*
|
|
31
|
+
* @throws A {@link RangeError} if the provided sign does not exist in the resolved zodiac set.
|
|
32
|
+
*
|
|
33
|
+
* @returns A metadata object describing the zodiac sign's position and date range.
|
|
34
|
+
*/
|
|
35
|
+
getZodiacMeta<Sign extends string = ZodiacSign>(sign: Sign, options?: ZodiacMetaOptions<Sign>): ZodiacMeta<Sign>;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** * Plugin to inject `zodiac` related methods */
|
|
39
|
+
declare const zodiacPlugin: ($Chronos: $Chronos) => void;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { zodiacPlugin };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { C as $Chronos, S as ZodiacSign, b as ZodiacOptions, v as ZodiacMeta, y as ZodiacMetaOptions } from "../types-B2fgrJ86.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugins/zodiacPlugin.d.ts
|
|
4
|
+
declare module '../' {
|
|
5
|
+
interface Chronos {
|
|
6
|
+
/**
|
|
7
|
+
* @instance Returns the zodiac sign based on current date or `birthDate` option.
|
|
8
|
+
* @param options Optional config to choose preset or provide custom zodiac date ranges.
|
|
9
|
+
* @returns The matching zodiac sign from preset/custom list.
|
|
10
|
+
*/
|
|
11
|
+
getZodiacSign<Sign extends string = ZodiacSign>(options?: ZodiacOptions<Sign>): Sign;
|
|
12
|
+
/**
|
|
13
|
+
* @instance Returns the zodiac sign based on current date or `birthDate` option.
|
|
14
|
+
* @remarks This method is an alias for {@link https://toolbox.nazmul-nhb.dev/docs/classes/Chronos/names#getzodiacsign getZodiacSign} method.
|
|
15
|
+
*
|
|
16
|
+
* @param options Optional config to choose preset or provide custom zodiac date ranges.
|
|
17
|
+
* @returns The matching zodiac sign from preset/custom list.
|
|
18
|
+
*/
|
|
19
|
+
zodiac<Sign extends string = ZodiacSign>(options?: ZodiacOptions<Sign>): Sign;
|
|
20
|
+
/**
|
|
21
|
+
* @instance Returns detailed metadata for a given zodiac sign based on the selected `preset` or custom ranges.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - The metadata includes the sign's `index` within the normalized zodiac order, its inclusive start and end dates.
|
|
25
|
+
* - **Note:** The returned `index` represents the chronological position of the zodiac sign based on Gregorian month–day ordering and may vary between different zodiac variants.
|
|
26
|
+
* - Handles year-boundary wrapping correctly (e.g. Capricorn, Sagittarius).
|
|
27
|
+
*
|
|
28
|
+
* @param sign The zodiac sign to retrieve metadata for.
|
|
29
|
+
* @param options Optional configuration to select a zodiac preset or provide custom ranges.
|
|
30
|
+
*
|
|
31
|
+
* @throws A {@link RangeError} if the provided sign does not exist in the resolved zodiac set.
|
|
32
|
+
*
|
|
33
|
+
* @returns A metadata object describing the zodiac sign's position and date range.
|
|
34
|
+
*/
|
|
35
|
+
getZodiacMeta<Sign extends string = ZodiacSign>(sign: Sign, options?: ZodiacMetaOptions<Sign>): ZodiacMeta<Sign>;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** * Plugin to inject `zodiac` related methods */
|
|
39
|
+
declare const zodiacPlugin: ($Chronos: $Chronos) => void;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { zodiacPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{m as e}from"../basic-e46DaNAi.mjs";import{f as t}from"../helpers-N1X_Rj_V.mjs";const n=n=>{function r(e){return e[0]*100+e[1]}function i(t){let{preset:n=`western`,custom:i}=t??{};return[...i??e[n]].sort((e,t)=>r(e[1])-r(t[1]))}n.prototype.getZodiacSign=function(e){let{birthDate:t}=e??{},n,r;t&&t?.includes(`-`)?[n,r]=t.split(`-`).map(Number):(n=this.isoMonth,r=this.date);let a=i(e);for(let e=a.length-1;e>=0;e--){let[t,[i,o]]=a[e];if(n>i||n===i&&r>=o)return t;if(e===0)return a.at(-1)[0]}return a[0][0]},n.prototype.zodiac=function(e){return this.getZodiacSign(e)},n.prototype.getZodiacMeta=function(e,n){let r=i(n),a=r.findIndex(([t])=>t===e);if(a===-1)throw RangeError(`Invalid zodiac sign: "${e}"`);let[o,s]=r[a][1],[c,l]=(r[a+1]??r[0])[1];return{index:a,sign:e,start:`${t(o)}-${t(s)}`,end:`${t(c)}-${t(l-1)}`}}};export{n as zodiacPlugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return typeof e==`number`&&Number.isFinite(e)}function t(e){return typeof e==`string`}function n(e){return typeof e==`boolean`}function r(e){return e===void 0}function i(e){return t(e)&&e?.length>0}export{r as a,t as i,i as n,e as r,n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return typeof e==`number`&&Number.isFinite(e)}function t(e){return typeof e==`string`}function n(e){return typeof e==`boolean`}function r(e){return e===void 0}function i(e){return t(e)&&e?.length>0}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze([{name:`Spring`,boundary:{startMonth:2,endMonth:4}},{name:`Summer`,boundary:{startMonth:5,endMonth:7}},{name:`Autumn`,boundary:{startMonth:8,endMonth:10}},{name:`Winter`,boundary:{startMonth:11,endMonth:1}}]),t=Object.freeze([{name:`Grisma (Summer)`,boundary:{startDate:`04-15`,endDate:`06-14`}},{name:`Barsa (Monsoon)`,boundary:{startDate:`06-15`,endDate:`08-14`}},{name:`Sarat (Autumn)`,boundary:{startDate:`08-15`,endDate:`10-14`}},{name:`Hemanta (Late-Autumn)`,boundary:{startDate:`10-15`,endDate:`12-14`}},{name:`Shhit (Winter)`,boundary:{startDate:`12-15`,endDate:`02-14`}},{name:`Basanta (Spring)`,boundary:{startDate:`02-15`,endDate:`04-14`}}]),n=Object.freeze([{name:`Winter`,boundary:{startMonth:0,endMonth:1}},{name:`Pre-Monsoon`,boundary:{startMonth:2,endMonth:4}},{name:`Monsoon`,boundary:{startMonth:5,endMonth:8}},{name:`Post-Monsoon`,boundary:{startMonth:9,endMonth:10}},{name:`Cool Season`,boundary:{startMonth:11,endMonth:11}}]),r=Object.freeze([{name:`Shishir (Winter)`,boundary:{startDate:`12-15`,endDate:`02-14`}},{name:`Vasanta (Spring)`,boundary:{startDate:`02-15`,endDate:`04-14`}},{name:`Grishma (Summer)`,boundary:{startDate:`04-15`,endDate:`06-14`}},{name:`Varsha (Monsoon)`,boundary:{startDate:`06-15`,endDate:`08-14`}},{name:`Sharad (Autumn)`,boundary:{startDate:`08-15`,endDate:`10-14`}},{name:`Hemant (Late-Autumn)`,boundary:{startDate:`10-15`,endDate:`12-14`}}]),i=Object.freeze([{name:`Ilavenil (Mid-Summer)`,boundary:{startMonth:4,endMonth:5}},{name:`Mutuvenil (Peak-Summer)`,boundary:{startMonth:6,endMonth:7}},{name:`Kaar (Monsoon)`,boundary:{startMonth:7,endMonth:9}},{name:`Koothir (Autumn)`,boundary:{startMonth:9,endMonth:10}},{name:`Munpani (Early-Winter)`,boundary:{startMonth:10,endMonth:0}},{name:`Pinpani (Late-Winter)`,boundary:{startMonth:0,endMonth:2}}]),a=Object.freeze([{name:`Dry Season`,boundary:{startMonth:11,endMonth:4}},{name:`Wet Season`,boundary:{startMonth:5,endMonth:10}}]),o=Object.freeze([{name:`Spring`,boundary:{startDate:`01-10`,endDate:`05-15`}},{name:`Summer`,boundary:{startDate:`05-16`,endDate:`08-15`}},{name:`Fall`,boundary:{startDate:`08-16`,endDate:`12-20`}},{name:`Winter Break`,boundary:{startDate:`12-21`,endDate:`01-09`}}]),s=Object.freeze([{name:`Haru (Spring)`,boundary:{startDate:`03-01`,endDate:`05-31`}},{name:`Natsu (Summer)`,boundary:{startDate:`06-01`,endDate:`08-31`}},{name:`Aki (Autumn)`,boundary:{startDate:`09-01`,endDate:`11-30`}},{name:`Fuyu (Winter)`,boundary:{startDate:`12-01`,endDate:`02-28`}}]),c=Object.freeze([{name:`Summer`,boundary:{startMonth:11,endMonth:1}},{name:`Autumn`,boundary:{startMonth:2,endMonth:4}},{name:`Winter`,boundary:{startMonth:5,endMonth:7}},{name:`Spring`,boundary:{startMonth:8,endMonth:10}}]),l=Object.freeze([{name:`Bega (Dry)`,boundary:{startMonth:10,endMonth:1}},{name:`Belg (Short Rain)`,boundary:{startMonth:2,endMonth:4}},{name:`Kiremt (Main Rain)`,boundary:{startMonth:5,endMonth:9}}]),u=Object.freeze({default:e,bangladesh:t,india:n,tamil:i,vedic:r,philippines:a,academic_us:o,japan:s,australia:c,ethiopia:l});export{n as a,s as c,o as d,l as i,a as l,t as n,i as o,e as r,r as s,c as t,u};
|