@ma.vu/appdate 0.0.7 → 0.1.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/dist/index.cjs +1 -1
- package/dist/index.d.cts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +1 -1
- package/dist/sr-ijekavian-6CKRA277.js +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var Y=Object.create;var m=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>(e&&(t=e(e=0)),t);var u=(e,t)=>{for(var a in t)m(e,a,{get:t[a],enumerable:!0})},c=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of T(t))!_.call(e,o)&&o!==a&&m(e,o,{get:()=>t[o],enumerable:!(i=S(t,o))||i.enumerable});return e};var s=(e,t,a)=>(a=e!=null?Y(w(e)):{},c(t||!e||!e.__esModule?m(a,"default",{value:e,enumerable:!0}):a,e)),A=e=>c(m({},"__esModule",{value:!0}),e);var D={};u(D,{default:()=>b});var O,b,l=k(()=>{"use strict";O={name:"sr-ije",weekdays:"Nedjelja_Ponedjeljak_Utorak_Srijeda_\u010Cetvrtak_Petak_Subota".split("_"),weekdaysShort:"Ned._Pon._Uto._Sri._\u010Cet._Pet._Sub.".split("_"),weekdaysMin:"ne_po_ut_sr_\u010De_pe_su".split("_"),months:"Januar_Februar_Mart_April_Maj_Jun_Jul_Avgust_Septembar_Oktobar_Novembar_Decembar".split("_"),monthsShort:"Jan._Feb._Mar._Apr._Maj_Jun_Jul_Avg._Sep._Okt._Nov._Dec.".split("_"),weekStart:1,ordinal:e=>`${e}.`,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"},relativeTime:{future:"za %s",past:"prije %s",s:"nekoliko sekundi",m:"jedan minut",mm:"%d minuta",h:"jedan sat",hh:"%d sati",d:"jedan dan",dd:"%d dana",M:"jedan mjesec",MM:"%d mjeseci",y:"jednu godinu",yy:"%d godina"}},b=O});var H={};u(H,{AppDate:()=>d,formatLocalTime:()=>F,getLocalizedDateString:()=>U,isDateString:()=>L,setAppDateLanguage:()=>x,setTimezone:()=>z});module.exports=A(H);var r=s(require("dayjs"),1),E=require("dayjs/locale/de"),f=s(require("dayjs/plugin/customParseFormat.js"),1),g=s(require("dayjs/plugin/isBetween.js"),1),j=s(require("dayjs/plugin/localizedFormat.js"),1),h=s(require("dayjs/plugin/timezone.js"),1),M=s(require("dayjs/plugin/utc.js"),1);r.default.extend(M.default);r.default.extend(h.default);r.default.extend(f.default);r.default.extend(g.default);r.default.extend(j.default);async function x(e){switch(e){case"de":{let t=await import("dayjs/locale/de-ch");r.default.locale(t.default);break}case"fr":{let t=await import("dayjs/locale/fr-ch");r.default.locale(t.default);break}case"sr":{let t=await import("dayjs/locale/sr");r.default.locale(t.default);break}case"sr-ije":{let t=await Promise.resolve().then(()=>(l(),D));r.default.locale(t.default,void 0,!0),r.default.locale("sr-ije");break}case"en":default:{let t=await import("dayjs/locale/en");r.default.locale(t.default);break}}}var n="Europe/Zurich";function z(e){n=e}var p="HH:mm",y="HH:mm:ssZ",d=class e{timezone;dayjsDate;static INVALID_DATE=(0,r.default)("");constructor(t,a,{invalid:i}={invalid:!1}){if(this.timezone=t,i){this.dayjsDate=e.INVALID_DATE;return}try{if(typeof a=="string"&&!L(a))throw new Error("Invalid Date string, we expect YYYY-DD-MM");this.dayjsDate=r.default.tz(a,t)}catch{console.warn("Could not parse date:",a),this.dayjsDate=e.INVALID_DATE}}static invalid(){return new e(n,"",{invalid:!0})}static now(){return new e(n,(0,r.default)())}static fromDateString(t){return new e(n,t)}static fromEpochSeconds(t){let a=r.default.unix(t);return new e(n,a)}static fromEpochMillis(t){let a=(0,r.default)(t);return new e(n,a)}static fromLocalTime(t){try{let a=r.default.tz(t,p,n);return new e(n,a)}catch(a){return a instanceof Error&&console.warn(`fromLocalTime(): ${a.message}`),e.invalid()}}static fromUtcString(t){let a=r.default.utc(t);return new e(n,a)}static fromUtcTime(t){let a=r.default.utc(t,y);return new e(n,a)}static minDate(){return e.fromDateString("1900-01-01")}static maxDate(){return e.fromDateString("2200-12-31")}add(t,a){let i=this.dayjsDate.add(t,a);return new e(n,i)}subtract(t,a){let i=this.dayjsDate.subtract(t,a);return new e(n,i)}startOf(t){let a=this.dayjsDate.startOf(t);return new e(n,a)}endOf(t){let a=this.dayjsDate.endOf(t);return new e(n,a)}tomorrow(){return this.add(1,"day")}isValid(){return this.dayjsDate.isValid()}isBefore(t,a){return this.dayjsDate.isBefore(t.dayjsDate,a)}isSame(t,a){return this.dayjsDate.isSame(t.dayjsDate,a)}isToday(){return this.dayjsDate.endOf("d").isSame((0,r.default)().endOf("d"))}isAfter(t,a){return this.dayjsDate.isAfter(t.dayjsDate,a)}isBetween(t=e.minDate(),a=e.maxDate(),i,o){return this.dayjsDate.isBetween(t.dayjsDate,a.dayjsDate,i,o??"[)")}isFirstDayOfWeek(){return this.dayjsDate.day()===1}isWorkingDay(){return v.includes(this.dayjsDate.day())}nextWorkingDay(){let t=this.add(1,"day");return t.isWorkingDay()?t:t.nextWorkingDay()}previousWorkingDay(){let t=this.subtract(1,"day");return t.isWorkingDay()?t:t.previousWorkingDay()}addWorkingDays(t){return t<=0||!Number.isInteger(t)?this:this.nextWorkingDay().addWorkingDays(t-1)}toLocalTime(){return this.format(p)}toUtcTime(){return this.dayjsDate.utc().format(y)}toDateString(){return this.format("YYYY-MM-DD")}toLocalizedDateString({includeDayOfWeek:t=!1}={}){let a=this.dayjsDate.format("L");return t?this.dayjsDate.format("dd, ")+a:a}toUtcDateString(){return this.dayjsDate.utc().format("YYYY-MM-DD")}toUtcString(){return this.dayjsDate.utc().format()}toEpochSeconds(){return this.dayjsDate.unix()}toEpochMillis(){return this.dayjsDate.valueOf()}format(t="YYYY-MM-DDTHH:mm:ssZ[Z]"){return this.dayjsDate.format(t)}formatShort({includeDayOfWeek:t=!0}={}){return t?this.format("dd, DD.MM."):this.format("DD.MM.")}formatDateTime({includeDayOfWeek:t=!0}={}){let a=this.toLocalizedDateString({includeDayOfWeek:t}),i=this.toLocalTime();return`${a}, ${i}`}},v=[1,2,3,4,5];function U(e,t){return d.fromDateString(e).toLocalizedDateString(t)}function F(e){return d.fromLocalTime(e).toLocalTime()}function L(e){return e?(0,r.default)(e,"YYYY-MM-DD",!0).isValid():!1}0&&(module.exports={AppDate,formatLocalTime,getLocalizedDateString,isDateString,setAppDateLanguage,setTimezone});
|
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,7 @@ import { Dayjs, ManipulateType, OpUnitType } from 'dayjs';
|
|
|
6
6
|
* de: 10.10.2010
|
|
7
7
|
* en: 10/10/2010
|
|
8
8
|
*/
|
|
9
|
-
declare function setAppDateLanguage(lang: "de" | "en" | "fr"): Promise<void>;
|
|
9
|
+
declare function setAppDateLanguage(lang: "de" | "en" | "fr" | "sr" | "sr-ije"): Promise<void>;
|
|
10
10
|
/**
|
|
11
11
|
* Change zone in runtime
|
|
12
12
|
*/
|
|
@@ -204,6 +204,28 @@ declare class AppDate {
|
|
|
204
204
|
toLocalizedDateString({ includeDayOfWeek, }?: LocalizedFormatOptions): string;
|
|
205
205
|
toUtcDateString(): DateString;
|
|
206
206
|
toUtcString(): string;
|
|
207
|
+
/**
|
|
208
|
+
* Converts the current date to a epoch seconds (unix timestamp).
|
|
209
|
+
*
|
|
210
|
+
* @returns The epoch seconds.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* const date = AppDate.now();
|
|
214
|
+
* console.log(date.toEpochSeconds()); // 1714732800
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
toEpochSeconds(): number;
|
|
218
|
+
/**
|
|
219
|
+
* Converts the current date to a epoch milliseconds (timestamp in milliseconds).
|
|
220
|
+
*
|
|
221
|
+
* @returns The epoch milliseconds.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* const date = AppDate.now();
|
|
225
|
+
* console.log(date.toEpochMillis()); // 1714732800000
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
toEpochMillis(): number;
|
|
207
229
|
/**
|
|
208
230
|
* Get the formatted date according to the string of tokens passed in.
|
|
209
231
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Dayjs, ManipulateType, OpUnitType } from 'dayjs';
|
|
|
6
6
|
* de: 10.10.2010
|
|
7
7
|
* en: 10/10/2010
|
|
8
8
|
*/
|
|
9
|
-
declare function setAppDateLanguage(lang: "de" | "en" | "fr"): Promise<void>;
|
|
9
|
+
declare function setAppDateLanguage(lang: "de" | "en" | "fr" | "sr" | "sr-ije"): Promise<void>;
|
|
10
10
|
/**
|
|
11
11
|
* Change zone in runtime
|
|
12
12
|
*/
|
|
@@ -204,6 +204,28 @@ declare class AppDate {
|
|
|
204
204
|
toLocalizedDateString({ includeDayOfWeek, }?: LocalizedFormatOptions): string;
|
|
205
205
|
toUtcDateString(): DateString;
|
|
206
206
|
toUtcString(): string;
|
|
207
|
+
/**
|
|
208
|
+
* Converts the current date to a epoch seconds (unix timestamp).
|
|
209
|
+
*
|
|
210
|
+
* @returns The epoch seconds.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* const date = AppDate.now();
|
|
214
|
+
* console.log(date.toEpochSeconds()); // 1714732800
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
toEpochSeconds(): number;
|
|
218
|
+
/**
|
|
219
|
+
* Converts the current date to a epoch milliseconds (timestamp in milliseconds).
|
|
220
|
+
*
|
|
221
|
+
* @returns The epoch milliseconds.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* const date = AppDate.now();
|
|
225
|
+
* console.log(date.toEpochMillis()); // 1714732800000
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
toEpochMillis(): number;
|
|
207
229
|
/**
|
|
208
230
|
* Get the formatted date according to the string of tokens passed in.
|
|
209
231
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import r from"dayjs";import"dayjs/locale/de";import
|
|
2
|
+
import r from"dayjs";import"dayjs/locale/de";import D from"dayjs/plugin/customParseFormat.js";import u from"dayjs/plugin/isBetween.js";import m from"dayjs/plugin/localizedFormat.js";import l from"dayjs/plugin/timezone.js";import p from"dayjs/plugin/utc.js";r.extend(p);r.extend(l);r.extend(D);r.extend(u);r.extend(m);async function S(a){switch(a){case"de":{let t=await import("dayjs/locale/de-ch");r.locale(t.default);break}case"fr":{let t=await import("dayjs/locale/fr-ch");r.locale(t.default);break}case"sr":{let t=await import("dayjs/locale/sr");r.locale(t.default);break}case"sr-ije":{let t=await import("./sr-ijekavian-6CKRA277.js");r.locale(t.default,void 0,!0),r.locale("sr-ije");break}case"en":default:{let t=await import("dayjs/locale/en");r.locale(t.default);break}}}var i="Europe/Zurich";function Y(a){i=a}var d="HH:mm",c="HH:mm:ssZ",s=class a{timezone;dayjsDate;static INVALID_DATE=r("");constructor(t,e,{invalid:n}={invalid:!1}){if(this.timezone=t,n){this.dayjsDate=a.INVALID_DATE;return}try{if(typeof e=="string"&&!f(e))throw new Error("Invalid Date string, we expect YYYY-DD-MM");this.dayjsDate=r.tz(e,t)}catch{console.warn("Could not parse date:",e),this.dayjsDate=a.INVALID_DATE}}static invalid(){return new a(i,"",{invalid:!0})}static now(){return new a(i,r())}static fromDateString(t){return new a(i,t)}static fromEpochSeconds(t){let e=r.unix(t);return new a(i,e)}static fromEpochMillis(t){let e=r(t);return new a(i,e)}static fromLocalTime(t){try{let e=r.tz(t,d,i);return new a(i,e)}catch(e){return e instanceof Error&&console.warn(`fromLocalTime(): ${e.message}`),a.invalid()}}static fromUtcString(t){let e=r.utc(t);return new a(i,e)}static fromUtcTime(t){let e=r.utc(t,c);return new a(i,e)}static minDate(){return a.fromDateString("1900-01-01")}static maxDate(){return a.fromDateString("2200-12-31")}add(t,e){let n=this.dayjsDate.add(t,e);return new a(i,n)}subtract(t,e){let n=this.dayjsDate.subtract(t,e);return new a(i,n)}startOf(t){let e=this.dayjsDate.startOf(t);return new a(i,e)}endOf(t){let e=this.dayjsDate.endOf(t);return new a(i,e)}tomorrow(){return this.add(1,"day")}isValid(){return this.dayjsDate.isValid()}isBefore(t,e){return this.dayjsDate.isBefore(t.dayjsDate,e)}isSame(t,e){return this.dayjsDate.isSame(t.dayjsDate,e)}isToday(){return this.dayjsDate.endOf("d").isSame(r().endOf("d"))}isAfter(t,e){return this.dayjsDate.isAfter(t.dayjsDate,e)}isBetween(t=a.minDate(),e=a.maxDate(),n,o){return this.dayjsDate.isBetween(t.dayjsDate,e.dayjsDate,n,o??"[)")}isFirstDayOfWeek(){return this.dayjsDate.day()===1}isWorkingDay(){return y.includes(this.dayjsDate.day())}nextWorkingDay(){let t=this.add(1,"day");return t.isWorkingDay()?t:t.nextWorkingDay()}previousWorkingDay(){let t=this.subtract(1,"day");return t.isWorkingDay()?t:t.previousWorkingDay()}addWorkingDays(t){return t<=0||!Number.isInteger(t)?this:this.nextWorkingDay().addWorkingDays(t-1)}toLocalTime(){return this.format(d)}toUtcTime(){return this.dayjsDate.utc().format(c)}toDateString(){return this.format("YYYY-MM-DD")}toLocalizedDateString({includeDayOfWeek:t=!1}={}){let e=this.dayjsDate.format("L");return t?this.dayjsDate.format("dd, ")+e:e}toUtcDateString(){return this.dayjsDate.utc().format("YYYY-MM-DD")}toUtcString(){return this.dayjsDate.utc().format()}toEpochSeconds(){return this.dayjsDate.unix()}toEpochMillis(){return this.dayjsDate.valueOf()}format(t="YYYY-MM-DDTHH:mm:ssZ[Z]"){return this.dayjsDate.format(t)}formatShort({includeDayOfWeek:t=!0}={}){return t?this.format("dd, DD.MM."):this.format("DD.MM.")}formatDateTime({includeDayOfWeek:t=!0}={}){let e=this.toLocalizedDateString({includeDayOfWeek:t}),n=this.toLocalTime();return`${e}, ${n}`}},y=[1,2,3,4,5];function O(a,t){return s.fromDateString(a).toLocalizedDateString(t)}function A(a){return s.fromLocalTime(a).toLocalTime()}function f(a){return a?r(a,"YYYY-MM-DD",!0).isValid():!1}export{s as AppDate,A as formatLocalTime,O as getLocalizedDateString,f as isDateString,S as setAppDateLanguage,Y as setTimezone};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var a={name:"sr-ije",weekdays:"Nedjelja_Ponedjeljak_Utorak_Srijeda_\u010Cetvrtak_Petak_Subota".split("_"),weekdaysShort:"Ned._Pon._Uto._Sri._\u010Cet._Pet._Sub.".split("_"),weekdaysMin:"ne_po_ut_sr_\u010De_pe_su".split("_"),months:"Januar_Februar_Mart_April_Maj_Jun_Jul_Avgust_Septembar_Oktobar_Novembar_Decembar".split("_"),monthsShort:"Jan._Feb._Mar._Apr._Maj_Jun_Jul_Avg._Sep._Okt._Nov._Dec.".split("_"),weekStart:1,ordinal:e=>`${e}.`,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY.",LLL:"D. MMMM YYYY. H:mm",LLLL:"dddd, D. MMMM YYYY. H:mm"},relativeTime:{future:"za %s",past:"prije %s",s:"nekoliko sekundi",m:"jedan minut",mm:"%d minuta",h:"jedan sat",hh:"%d sati",d:"jedan dan",dd:"%d dana",M:"jedan mjesec",MM:"%d mjeseci",y:"jednu godinu",yy:"%d godina"}},_=a;export{_ as default};
|
package/package.json
CHANGED