@equinor/amplify-component-lib 9.9.1 → 9.9.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.
@@ -10,12 +10,12 @@ type FormatDateOptions = {
10
10
  */
11
11
  export declare const formatDate: (date: Date | string | null | undefined, options?: FormatDateOptions & {
12
12
  useUTC?: boolean;
13
- }) => string;
13
+ }) => string | undefined;
14
14
  export declare const formatDateTime: (date: Date | string | null | undefined, options?: {
15
15
  month?: "short" | "long";
16
16
  hideYear?: boolean;
17
17
  isGMT?: boolean;
18
- }) => string;
19
- export declare const formatRelativeDateTime: (date: Date | string | null | undefined, isGMT?: boolean) => string;
18
+ }) => string | undefined;
19
+ export declare const formatRelativeDateTime: (date: Date | string | null | undefined, isGMT?: boolean) => string | undefined;
20
20
  export declare const isBetweenDates: (date: Date | string | null | undefined, dates: [Date, Date]) => boolean;
21
21
  export {};
@@ -1 +1 @@
1
- const t=(t,e={format:"DD. month YYYY",month:"long"})=>{if(t){const n=new Date(t);if(n.getTime()){if("DD. month YYYY"===e?.format){return`${n.toLocaleDateString("en-GB",{day:"numeric",timeZone:e.useUTC?"UTC":void 0})}. ${n.toLocaleString("en-GB",{month:e?.month??"long",year:"numeric",timeZone:e.useUTC?"UTC":void 0})}`}const t=e?.useUTC?n.getUTCDate():n.getDate(),o=e?.useUTC?n.getUTCMonth()+1:n.getMonth()+1,i=e?.useUTC?n.getUTCFullYear():n.getFullYear();if("DD. month"===e?.format){return`${n.toLocaleDateString("en-GB",{day:"numeric",timeZone:e.useUTC?"UTC":void 0})}. ${n.toLocaleString("en-GB",{month:e.month??"long",timeZone:e.useUTC?"UTC":void 0})}`}return"YYYY-MM-DD"===e?.format?`${i.toString().padStart(4,"0")}-${o.toString().padStart(2,"0")}-${t.toString().padStart(2,"0")}`:"DD.MM.YY"===e?.format?`${t.toString().padStart(2,"0")}.${o.toString().padStart(2,"0")}.${i.toString().padStart(4,"0").slice(-2)}`:`${t.toString().padStart(2,"0")}.${o.toString().padStart(2,"0")}.${i.toString().padStart(4,"0")}`}}return""},e=(t,e={month:"long",hideYear:!1,isGMT:!1})=>{if(t){const n=new Date(t);if(n.getTime()){e.isGMT&&n.setTime(n.getTime()+6e4*n.getTimezoneOffset());return`${n.toLocaleDateString("en-GB",{day:"numeric"})}. ${n.toLocaleString("en-GB",{month:e.month??"long",year:e.hideYear?void 0:"numeric",hour:"2-digit",minute:"2-digit"})}`}}return""},n=(t,n=!1)=>{if(t){const o=new Date(t),i=new Date;if(o.getTime()){n&&o.setTime(o.getTime()+6e4*o.getTimezoneOffset());const r=(o<i?i.getTime()-o.getTime():o.getTime()-i.getTime())/864e5,a=o.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return r<1&&o.getDate()===i.getDate()?`Today at ${a}`:r<2&&o<i?`Yesterday at ${a}`:r<2&&r>=0?`Tomorrow at ${a}`:r>2&&r<7&&o>i?`${o.toLocaleString("en-GB",{weekday:"long"})} at ${a}`:e(t,{hideYear:o.getFullYear()===i.getFullYear()})}}return""},o=(t,e)=>{if(t){if(new Date(t).getTime())return t>=e[0]&&t<=e[1]}return!1};export{t as formatDate,e as formatDateTime,n as formatRelativeDateTime,o as isBetweenDates};
1
+ const t=(t,e={format:"DD. month YYYY",month:"long"})=>{if(t){const n=new Date(t);if(n.getTime()){if("DD. month YYYY"===e?.format){return`${n.toLocaleDateString("en-GB",{day:"numeric",timeZone:e.useUTC?"UTC":void 0})}. ${n.toLocaleString("en-GB",{month:e?.month??"long",year:"numeric",timeZone:e.useUTC?"UTC":void 0})}`}const t=e?.useUTC?n.getUTCDate():n.getDate(),o=e?.useUTC?n.getUTCMonth()+1:n.getMonth()+1,i=e?.useUTC?n.getUTCFullYear():n.getFullYear();if("DD. month"===e?.format){return`${n.toLocaleDateString("en-GB",{day:"numeric",timeZone:e.useUTC?"UTC":void 0})}. ${n.toLocaleString("en-GB",{month:e.month??"long",timeZone:e.useUTC?"UTC":void 0})}`}return"YYYY-MM-DD"===e?.format?`${i.toString().padStart(4,"0")}-${o.toString().padStart(2,"0")}-${t.toString().padStart(2,"0")}`:"DD.MM.YY"===e?.format?`${t.toString().padStart(2,"0")}.${o.toString().padStart(2,"0")}.${i.toString().padStart(4,"0").slice(-2)}`:`${t.toString().padStart(2,"0")}.${o.toString().padStart(2,"0")}.${i.toString().padStart(4,"0")}`}}},e=(t,e={month:"long",hideYear:!1,isGMT:!1})=>{if(t){const n=new Date(t);if(n.getTime()){e.isGMT&&n.setTime(n.getTime()+6e4*n.getTimezoneOffset());return`${n.toLocaleDateString("en-GB",{day:"numeric"})}. ${n.toLocaleString("en-GB",{month:e.month??"long",year:e.hideYear?void 0:"numeric",hour:"2-digit",minute:"2-digit"})}`}}},n=(t,n=!1)=>{if(t){const o=new Date(t),i=new Date;if(o.getTime()){n&&o.setTime(o.getTime()+6e4*o.getTimezoneOffset());const r=(o<i?i.getTime()-o.getTime():o.getTime()-i.getTime())/864e5,a=o.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return r<1&&o.getDate()===i.getDate()?`Today at ${a}`:r<2&&o<i?`Yesterday at ${a}`:r<2&&r>=0?`Tomorrow at ${a}`:r>2&&r<7&&o>i?`${o.toLocaleString("en-GB",{weekday:"long"})} at ${a}`:e(t,{hideYear:o.getFullYear()===i.getFullYear()})}}},o=(t,e)=>{if(t){if(new Date(t).getTime())return t>=e[0]&&t<=e[1]}return!1};export{t as formatDate,e as formatDateTime,n as formatRelativeDateTime,o as isBetweenDates};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/amplify-component-lib",
3
- "version": "9.9.1",
3
+ "version": "9.9.2",
4
4
  "description": "Frontend Typescript components for the Amplify team",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",