@webority/mobile-core 0.178.1 → 0.178.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatDate=formatDate,exports.formatDateTime=formatDateTime,exports.formatRelativeTime=void 0,exports.formatTime=formatTime;var _house=require("./house.js"),_intlCache=require("./intlCache.js");const toDate=e=>{if(null==e)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;const t=new Date(e);return Number.isNaN(t.getTime())?null:t},isStyle=e=>"string"==typeof e;function formatDate(e,t,r="en-IN"){if(!isStyle(t))return(0,_house.formatDate)(e,t);const o=t,a=toDate(e);if(!a)return"";try{return(0,_intlCache.dateTimeFormat)(r,{dateStyle:o}).format(a)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatDate rejected style "${o}" or locale "${r}": ${e.message}`,{cause:e});throw e}}function formatTime(e,t,r="en-IN"){if(!isStyle(t))return(0,_house.formatTime)(e,t);const o=t,a=toDate(e);if(!a)return"";try{return(0,_intlCache.dateTimeFormat)(r,{timeStyle:o}).format(a)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatTime rejected style "${o}" or locale "${r}": ${e.message}`,{cause:e});throw e}}function formatDateTime(e,t,r="short",o="en-IN"){if(!isStyle(t))return(0,_house.formatDateTime)(e,t);const a=t,i=toDate(e);if(!i)return"";try{return(0,_intlCache.dateTimeFormat)(o,{dateStyle:a,timeStyle:r}).format(i)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatDateTime rejected styles "${a}"/"${r}" or locale "${o}": ${e.message}`,{cause:e});throw e}}const SECOND=1e3,MINUTE=6e4,HOUR=36e5,DAY=24*HOUR,WEEK=7*DAY,MONTH=30*DAY,YEAR=365*DAY,formatRelativeTime=(e,t=new Date,r="en-IN")=>{const o=toDate(e),a=toDate(t);if(!o||!a)return"";const i=o.getTime()-a.getTime(),n=Math.abs(i);let m,s;n<6e4?(m="second",s=Math.round(i/1e3)):n<HOUR?(m="minute",s=Math.round(i/6e4)):n<DAY?(m="hour",s=Math.round(i/HOUR)):n<WEEK?(m="day",s=Math.round(i/DAY)):n<MONTH?(m="week",s=Math.round(i/WEEK)):n<YEAR?(m="month",s=Math.round(i/MONTH)):(m="year",s=Math.round(i/YEAR))
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatDate=formatDate,exports.formatDateTime=formatDateTime,exports.formatRelativeTime=void 0,exports.formatTime=formatTime;var _house=require("./house.js"),_intlCache=require("./intlCache.js");const toDate=e=>{if(null==e)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;const t=new Date(e);return Number.isNaN(t.getTime())?null:t},isStyle=e=>"string"==typeof e;function formatDate(e,t,r="en-IN"){if(!isStyle(t))return(0,_house.formatDate)(e,t);const o=t,a=toDate(e);if(!a)return"";try{return(0,_intlCache.dateTimeFormat)(r,{dateStyle:o}).format(a)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatDate rejected style "${o}" or locale "${r}": ${e.message}`,{cause:e});throw e}}function formatTime(e,t,r="en-IN"){if(!isStyle(t))return(0,_house.formatTime)(e,t);const o=t,a=toDate(e);if(!a)return"";try{return(0,_intlCache.dateTimeFormat)(r,{timeStyle:o}).format(a)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatTime rejected style "${o}" or locale "${r}": ${e.message}`,{cause:e});throw e}}function formatDateTime(e,t,r="short",o="en-IN"){if(!isStyle(t))return(0,_house.formatDateTime)(e,t);const a=t,i=toDate(e);if(!i)return"";try{return(0,_intlCache.dateTimeFormat)(o,{dateStyle:a,timeStyle:r}).format(i)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatDateTime rejected styles "${a}"/"${r}" or locale "${o}": ${e.message}`,{cause:e});throw e}}const SECOND=1e3,MINUTE=6e4,HOUR=36e5,DAY=24*HOUR,WEEK=7*DAY,MONTH=30*DAY,YEAR=365*DAY,formatRelativeTime=(e,t=new Date,r="en-IN")=>{const o=toDate(e),a=toDate(t);if(!o||!a)return"";const i=o.getTime()-a.getTime(),n=Math.abs(i);let m,s;if(n<6e4?(m="second",s=Math.round(i/1e3)):n<HOUR?(m="minute",s=Math.round(i/6e4)):n<DAY?(m="hour",s=Math.round(i/HOUR)):n<WEEK?(m="day",s=Math.round(i/DAY)):n<MONTH?(m="week",s=Math.round(i/WEEK)):n<YEAR?(m="month",s=Math.round(i/MONTH)):(m="year",s=Math.round(i/YEAR)),"function"==typeof Intl.RelativeTimeFormat)try{return(0,_intlCache.relativeTimeFormat)(Intl.RelativeTimeFormat,r).format(s,m)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatRelativeTime rejected locale "${r}": ${e.message}`,{cause:e});throw e}const c=Math.abs(s),f=1===c?m:`${m}s`;return s<0?`${c} ${f} ago`:`in ${c} ${f}`};exports.formatRelativeTime=formatRelativeTime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{formatDate as houseDate,formatDateTime as houseDateTime,formatTime as houseTime}from"./house.js";import{dateTimeFormat,relativeTimeFormat}from"./intlCache.js";const toDate=e=>{if(null==e)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;const t=new Date(e);return Number.isNaN(t.getTime())?null:t},isStyle=e=>"string"==typeof e;export function formatDate(e,t,r="en-IN"){if(!isStyle(t))return houseDate(e,t);const o=t,a=toDate(e);if(!a)return"";try{return dateTimeFormat(r,{dateStyle:o}).format(a)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatDate rejected style "${o}" or locale "${r}": ${e.message}`,{cause:e});throw e}}export function formatTime(e,t,r="en-IN"){if(!isStyle(t))return houseTime(e,t);const o=t,a=toDate(e);if(!a)return"";try{return dateTimeFormat(r,{timeStyle:o}).format(a)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatTime rejected style "${o}" or locale "${r}": ${e.message}`,{cause:e});throw e}}export function formatDateTime(e,t,r="short",o="en-IN"){if(!isStyle(t))return houseDateTime(e,t);const a=t,n=toDate(e);if(!n)return"";try{return dateTimeFormat(o,{dateStyle:a,timeStyle:r}).format(n)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatDateTime rejected styles "${a}"/"${r}" or locale "${o}": ${e.message}`,{cause:e});throw e}}const SECOND=1e3,MINUTE=6e4,HOUR=36e5,DAY=24*HOUR,WEEK=7*DAY,MONTH=30*DAY,YEAR=365*DAY;export const formatRelativeTime=(e,t=new Date,r="en-IN")=>{const o=toDate(e),a=toDate(t);if(!o||!a)return"";const n=o.getTime()-a.getTime(),i=Math.abs(n);let m,s;i<6e4?(m="second",s=Math.round(n/1e3)):i<HOUR?(m="minute",s=Math.round(n/6e4)):i<DAY?(m="hour",s=Math.round(n/HOUR)):i<WEEK?(m="day",s=Math.round(n/DAY)):i<MONTH?(m="week",s=Math.round(n/WEEK)):i<YEAR?(m="month",s=Math.round(n/MONTH)):(m="year",s=Math.round(n/YEAR))
|
|
1
|
+
"use strict";import{formatDate as houseDate,formatDateTime as houseDateTime,formatTime as houseTime}from"./house.js";import{dateTimeFormat,relativeTimeFormat}from"./intlCache.js";const toDate=e=>{if(null==e)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;const t=new Date(e);return Number.isNaN(t.getTime())?null:t},isStyle=e=>"string"==typeof e;export function formatDate(e,t,r="en-IN"){if(!isStyle(t))return houseDate(e,t);const o=t,a=toDate(e);if(!a)return"";try{return dateTimeFormat(r,{dateStyle:o}).format(a)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatDate rejected style "${o}" or locale "${r}": ${e.message}`,{cause:e});throw e}}export function formatTime(e,t,r="en-IN"){if(!isStyle(t))return houseTime(e,t);const o=t,a=toDate(e);if(!a)return"";try{return dateTimeFormat(r,{timeStyle:o}).format(a)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatTime rejected style "${o}" or locale "${r}": ${e.message}`,{cause:e});throw e}}export function formatDateTime(e,t,r="short",o="en-IN"){if(!isStyle(t))return houseDateTime(e,t);const a=t,n=toDate(e);if(!n)return"";try{return dateTimeFormat(o,{dateStyle:a,timeStyle:r}).format(n)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatDateTime rejected styles "${a}"/"${r}" or locale "${o}": ${e.message}`,{cause:e});throw e}}const SECOND=1e3,MINUTE=6e4,HOUR=36e5,DAY=24*HOUR,WEEK=7*DAY,MONTH=30*DAY,YEAR=365*DAY;export const formatRelativeTime=(e,t=new Date,r="en-IN")=>{const o=toDate(e),a=toDate(t);if(!o||!a)return"";const n=o.getTime()-a.getTime(),i=Math.abs(n);let m,s;if(i<6e4?(m="second",s=Math.round(n/1e3)):i<HOUR?(m="minute",s=Math.round(n/6e4)):i<DAY?(m="hour",s=Math.round(n/HOUR)):i<WEEK?(m="day",s=Math.round(n/DAY)):i<MONTH?(m="week",s=Math.round(n/WEEK)):i<YEAR?(m="month",s=Math.round(n/MONTH)):(m="year",s=Math.round(n/YEAR)),"function"==typeof Intl.RelativeTimeFormat)try{return relativeTimeFormat(Intl.RelativeTimeFormat,r).format(s,m)}catch(e){if(e instanceof RangeError)throw new RangeError(`[@webority/mobile-core] formatRelativeTime rejected locale "${r}": ${e.message}`,{cause:e});throw e}const c=Math.abs(s),u=1===c?m:`${m}s`;return s<0?`${c} ${u} ago`:`in ${c} ${u}`};
|
|
@@ -16,7 +16,8 @@ export declare function formatDateTime(value: DateValue, options?: FormatDateTim
|
|
|
16
16
|
export declare function formatDateTime(value: DateInput, dateStyle: DateStyle, timeStyle?: TimeStyle, locale?: string): string;
|
|
17
17
|
/**
|
|
18
18
|
* Returns a humanized relative-time string (e.g. "5 minutes ago", "in 3 days").
|
|
19
|
-
* Uses `Intl.RelativeTimeFormat
|
|
19
|
+
* Uses `Intl.RelativeTimeFormat` where the engine has it. Hermes on Android ships without it, so there
|
|
20
|
+
* the string is built in English.
|
|
20
21
|
*/
|
|
21
22
|
export declare const formatRelativeTime: (value: DateInput, base?: DateInput, locale?: string) => string;
|
|
22
23
|
//# sourceMappingURL=date.d.ts.map
|
|
@@ -16,7 +16,8 @@ export declare function formatDateTime(value: DateValue, options?: FormatDateTim
|
|
|
16
16
|
export declare function formatDateTime(value: DateInput, dateStyle: DateStyle, timeStyle?: TimeStyle, locale?: string): string;
|
|
17
17
|
/**
|
|
18
18
|
* Returns a humanized relative-time string (e.g. "5 minutes ago", "in 3 days").
|
|
19
|
-
* Uses `Intl.RelativeTimeFormat
|
|
19
|
+
* Uses `Intl.RelativeTimeFormat` where the engine has it. Hermes on Android ships without it, so there
|
|
20
|
+
* the string is built in English.
|
|
20
21
|
*/
|
|
21
22
|
export declare const formatRelativeTime: (value: DateInput, base?: DateInput, locale?: string) => string;
|
|
22
23
|
//# sourceMappingURL=date.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/mobile-core",
|
|
3
|
-
"version": "0.178.
|
|
3
|
+
"version": "0.178.2",
|
|
4
4
|
"description": "Platform layer for Webority React Native apps: HTTP clients, auth/token storage, config, logging, formatters, validators, network status, permissions, storage, version checks and over-the-air updates. No UI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -399,7 +399,7 @@
|
|
|
399
399
|
}
|
|
400
400
|
},
|
|
401
401
|
"dependencies": {
|
|
402
|
-
"@webority/api-contract": "0.178.
|
|
402
|
+
"@webority/api-contract": "0.178.2",
|
|
403
403
|
"axios": "^1.19.0",
|
|
404
404
|
"libphonenumber-js": "^1.12.41"
|
|
405
405
|
},
|