@itwin/components-react 3.3.0-dev.42 → 3.3.0-dev.46
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/lib/cjs/components-react/common/DateUtils.d.ts +12 -2
- package/lib/cjs/components-react/common/DateUtils.d.ts.map +1 -1
- package/lib/cjs/components-react/common/DateUtils.js +14 -4
- package/lib/cjs/components-react/common/DateUtils.js.map +1 -1
- package/lib/esm/components-react/common/DateUtils.d.ts +12 -2
- package/lib/esm/components-react/common/DateUtils.d.ts.map +1 -1
- package/lib/esm/components-react/common/DateUtils.js +12 -2
- package/lib/esm/components-react/common/DateUtils.js.map +1 -1
- package/package.json +11 -11
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Common
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Define formatting options for use when component are generating a formatted date string calling `Date.toLocaleTimeString()`.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface DateFormatOptions {
|
|
9
|
+
locales?: string | string[] | undefined;
|
|
10
|
+
options?: Intl.DateTimeFormatOptions | undefined;
|
|
11
|
+
}
|
|
4
12
|
/**
|
|
5
13
|
* Adjust a Date object to show time in one time zone as if it is in the local time zone.
|
|
6
14
|
* This is useful when showing sunrise and sunset times for a project location in a different time zone
|
|
@@ -34,16 +42,18 @@ export declare function adjustDateToTimezone(inDateTime: Date, utcOffset: number
|
|
|
34
42
|
* Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset
|
|
35
43
|
* @param date Date object to format
|
|
36
44
|
* @param timeZoneOffset optional: offset from UTC to use for conversion
|
|
45
|
+
* @param formatOptions optional: allow locale and format for output Date string. If not defined current locale options are used.
|
|
37
46
|
* @returns formatted date string
|
|
38
47
|
* @public
|
|
39
48
|
*/
|
|
40
|
-
export declare const toDateString: (date: Date, timeZoneOffset?: number | undefined) => string;
|
|
49
|
+
export declare const toDateString: (date: Date, timeZoneOffset?: number | undefined, formatOptions?: DateFormatOptions | undefined) => string;
|
|
41
50
|
/**
|
|
42
51
|
* Format the time included in a date, optionally converting to time zone, if specified
|
|
43
52
|
* @param date Date object
|
|
44
53
|
* @param timeZoneOffset optional: offset from UTC to use for conversion
|
|
54
|
+
* @param formatOptions optional: allow locale and format for output Time string. If not defined current locale options are used.
|
|
45
55
|
* @returns formatted time string
|
|
46
56
|
* @public
|
|
47
57
|
*/
|
|
48
|
-
export declare const toTimeString: (date: Date, timeZoneOffset?: number | undefined) => string;
|
|
58
|
+
export declare const toTimeString: (date: Date, timeZoneOffset?: number | undefined, formatOptions?: DateFormatOptions | undefined) => string;
|
|
49
59
|
//# sourceMappingURL=DateUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateUtils.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAEvE;AACD
|
|
1
|
+
{"version":3,"file":"DateUtils.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAEvE;AACD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,SAAU,IAAI,+FAMtC,CAAC;AACF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,SAAU,IAAI,+FAMtC,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toTimeString = exports.toDateString = exports.adjustDateToTimezone = void 0;
|
|
4
2
|
/*---------------------------------------------------------------------------------------------
|
|
5
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -8,6 +6,8 @@ exports.toTimeString = exports.toDateString = exports.adjustDateToTimezone = voi
|
|
|
8
6
|
/** @packageDocumentation
|
|
9
7
|
* @module Common
|
|
10
8
|
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.toTimeString = exports.toDateString = exports.adjustDateToTimezone = void 0;
|
|
11
11
|
/**
|
|
12
12
|
* Adjust a Date object to show time in one time zone as if it is in the local time zone.
|
|
13
13
|
* This is useful when showing sunrise and sunset times for a project location in a different time zone
|
|
@@ -44,10 +44,15 @@ exports.adjustDateToTimezone = adjustDateToTimezone;
|
|
|
44
44
|
* Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset
|
|
45
45
|
* @param date Date object to format
|
|
46
46
|
* @param timeZoneOffset optional: offset from UTC to use for conversion
|
|
47
|
+
* @param formatOptions optional: allow locale and format for output Date string. If not defined current locale options are used.
|
|
47
48
|
* @returns formatted date string
|
|
48
49
|
* @public
|
|
49
50
|
*/
|
|
50
|
-
const toDateString = (date, timeZoneOffset) => {
|
|
51
|
+
const toDateString = (date, timeZoneOffset, formatOptions) => {
|
|
52
|
+
if (formatOptions) {
|
|
53
|
+
return undefined === timeZoneOffset ? date.toLocaleDateString(formatOptions.locales, formatOptions.options) :
|
|
54
|
+
adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString(formatOptions.locales, formatOptions.options);
|
|
55
|
+
}
|
|
51
56
|
return undefined === timeZoneOffset ? date.toLocaleDateString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString();
|
|
52
57
|
};
|
|
53
58
|
exports.toDateString = toDateString;
|
|
@@ -55,10 +60,15 @@ exports.toDateString = toDateString;
|
|
|
55
60
|
* Format the time included in a date, optionally converting to time zone, if specified
|
|
56
61
|
* @param date Date object
|
|
57
62
|
* @param timeZoneOffset optional: offset from UTC to use for conversion
|
|
63
|
+
* @param formatOptions optional: allow locale and format for output Time string. If not defined current locale options are used.
|
|
58
64
|
* @returns formatted time string
|
|
59
65
|
* @public
|
|
60
66
|
*/
|
|
61
|
-
const toTimeString = (date, timeZoneOffset) => {
|
|
67
|
+
const toTimeString = (date, timeZoneOffset, formatOptions) => {
|
|
68
|
+
if (formatOptions) {
|
|
69
|
+
return undefined === timeZoneOffset ? date.toLocaleTimeString(formatOptions.locales, formatOptions.options) :
|
|
70
|
+
adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString(formatOptions.locales, formatOptions.options);
|
|
71
|
+
}
|
|
62
72
|
return undefined === timeZoneOffset ? date.toLocaleTimeString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString();
|
|
63
73
|
};
|
|
64
74
|
exports.toTimeString = toTimeString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateUtils.js","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateUtils.js","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAWH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,oBAAoB,CAAC,UAAgB,EAAE,SAAiB;IACtE,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,iBAAiB,EAAE,GAAG,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC;AAC/F,CAAC;AAFD,oDAEC;AACD;;;;;;;GAOG;AACI,MAAM,YAAY,GAAG,CAAC,IAAU,EAAE,cAAuB,EAAE,aAAiC,EAAE,EAAE;IACrG,IAAI,aAAa,EAAE;QACjB,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3G,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;KAC/G;IACD,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpI,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB;AACF;;;;;;;GAOG;AACI,MAAM,YAAY,GAAG,CAAC,IAAU,EAAE,cAAuB,EAAE,aAAiC,EAAE,EAAE;IACrG,IAAI,aAAa,EAAE;QACjB,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3G,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;KAC/G;IACD,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpI,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/**\r\n * Define formatting options for use when component are generating a formatted date string calling `Date.toLocaleTimeString()`.\r\n * @public\r\n */\r\nexport interface DateFormatOptions {\r\n locales?: string | string[] | undefined;\r\n options?: Intl.DateTimeFormatOptions | undefined;\r\n}\r\n\r\n/**\r\n * Adjust a Date object to show time in one time zone as if it is in the local time zone.\r\n * This is useful when showing sunrise and sunset times for a project location in a different time zone\r\n * and the time displayed should appear as if the user is seeing clock in project location.\r\n * Example 1:\r\n * If you have a UTC time for London (UTC +0100) and you want to display it in Eastern-US (UTC -0400) as if you were in London.\r\n * ```ts\r\n * londonDate = new Date(\"July 22, 2018 07:22:13 +0100\");\r\n * in Eastern-US londonDate will show as '7/22/2018, 2:22:13 AM'\r\n * adjustedDate = adjustDateToTimezone(londonDate, 1*60);\r\n * in location Eastern-US adjustedDate will show as '7/22/2018, 7:22:13 AM'\r\n * ```\r\n * Example 2:\r\n * If you have a UTC time for your location (UTC -0400) and you want to display the time as if you are in Western-US (UTC -0700).\r\n * ```ts\r\n * easternDate = new Date(\"July 22, 2018 07:22:13 -0400\");\r\n * adjustedDate = adjustDateToTimezone(easternDate, -7*60);\r\n * in location Eastern-US adjustedDate will show as '7/22/2018, 7:22:13 AM'\r\n * ```\r\n *\r\n * The utcOffset must be the time in minutes between the UTC and the desired time zone at the date specified by inDateTime.\r\n * For example, if you want the time offset to New York, NY and the date is during Daylight Saving Time, utcOffset should be -240 (-4 * 60).\r\n * If the date falls during Standard Time in New York, utcOffset will be -300 (-5 * 60).\r\n *\r\n * @param inDateTime date/time at project location\r\n * @param utcOffset UTC offset in minutes\r\n * @public\r\n */\r\nexport function adjustDateToTimezone(inDateTime: Date, utcOffset: number) {\r\n return new Date(inDateTime.getTime() + (inDateTime.getTimezoneOffset() + utcOffset) * 60000);\r\n}\r\n/**\r\n * Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset\r\n * @param date Date object to format\r\n * @param timeZoneOffset optional: offset from UTC to use for conversion\r\n * @param formatOptions optional: allow locale and format for output Date string. If not defined current locale options are used.\r\n * @returns formatted date string\r\n * @public\r\n */\r\nexport const toDateString = (date: Date, timeZoneOffset?: number, formatOptions?: DateFormatOptions) => {\r\n if (formatOptions) {\r\n return undefined === timeZoneOffset ? date.toLocaleDateString(formatOptions.locales, formatOptions.options) :\r\n adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString(formatOptions.locales, formatOptions.options);\r\n }\r\n return undefined === timeZoneOffset ? date.toLocaleDateString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString();\r\n};\r\n/**\r\n * Format the time included in a date, optionally converting to time zone, if specified\r\n * @param date Date object\r\n * @param timeZoneOffset optional: offset from UTC to use for conversion\r\n * @param formatOptions optional: allow locale and format for output Time string. If not defined current locale options are used.\r\n * @returns formatted time string\r\n * @public\r\n */\r\nexport const toTimeString = (date: Date, timeZoneOffset?: number, formatOptions?: DateFormatOptions) => {\r\n if (formatOptions) {\r\n return undefined === timeZoneOffset ? date.toLocaleTimeString(formatOptions.locales, formatOptions.options) :\r\n adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString(formatOptions.locales, formatOptions.options);\r\n }\r\n return undefined === timeZoneOffset ? date.toLocaleTimeString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString();\r\n};\r\n\r\n"]}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Common
|
|
3
3
|
*/
|
|
4
|
+
/**
|
|
5
|
+
* Define formatting options for use when component are generating a formatted date string calling `Date.toLocaleTimeString()`.
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface DateFormatOptions {
|
|
9
|
+
locales?: string | string[] | undefined;
|
|
10
|
+
options?: Intl.DateTimeFormatOptions | undefined;
|
|
11
|
+
}
|
|
4
12
|
/**
|
|
5
13
|
* Adjust a Date object to show time in one time zone as if it is in the local time zone.
|
|
6
14
|
* This is useful when showing sunrise and sunset times for a project location in a different time zone
|
|
@@ -34,16 +42,18 @@ export declare function adjustDateToTimezone(inDateTime: Date, utcOffset: number
|
|
|
34
42
|
* Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset
|
|
35
43
|
* @param date Date object to format
|
|
36
44
|
* @param timeZoneOffset optional: offset from UTC to use for conversion
|
|
45
|
+
* @param formatOptions optional: allow locale and format for output Date string. If not defined current locale options are used.
|
|
37
46
|
* @returns formatted date string
|
|
38
47
|
* @public
|
|
39
48
|
*/
|
|
40
|
-
export declare const toDateString: (date: Date, timeZoneOffset?: number | undefined) => string;
|
|
49
|
+
export declare const toDateString: (date: Date, timeZoneOffset?: number | undefined, formatOptions?: DateFormatOptions | undefined) => string;
|
|
41
50
|
/**
|
|
42
51
|
* Format the time included in a date, optionally converting to time zone, if specified
|
|
43
52
|
* @param date Date object
|
|
44
53
|
* @param timeZoneOffset optional: offset from UTC to use for conversion
|
|
54
|
+
* @param formatOptions optional: allow locale and format for output Time string. If not defined current locale options are used.
|
|
45
55
|
* @returns formatted time string
|
|
46
56
|
* @public
|
|
47
57
|
*/
|
|
48
|
-
export declare const toTimeString: (date: Date, timeZoneOffset?: number | undefined) => string;
|
|
58
|
+
export declare const toTimeString: (date: Date, timeZoneOffset?: number | undefined, formatOptions?: DateFormatOptions | undefined) => string;
|
|
49
59
|
//# sourceMappingURL=DateUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateUtils.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAEvE;AACD
|
|
1
|
+
{"version":3,"file":"DateUtils.d.ts","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACxC,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,QAEvE;AACD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,SAAU,IAAI,+FAMtC,CAAC;AACF;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,SAAU,IAAI,+FAMtC,CAAC"}
|
|
@@ -40,20 +40,30 @@ export function adjustDateToTimezone(inDateTime, utcOffset) {
|
|
|
40
40
|
* Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset
|
|
41
41
|
* @param date Date object to format
|
|
42
42
|
* @param timeZoneOffset optional: offset from UTC to use for conversion
|
|
43
|
+
* @param formatOptions optional: allow locale and format for output Date string. If not defined current locale options are used.
|
|
43
44
|
* @returns formatted date string
|
|
44
45
|
* @public
|
|
45
46
|
*/
|
|
46
|
-
export const toDateString = (date, timeZoneOffset) => {
|
|
47
|
+
export const toDateString = (date, timeZoneOffset, formatOptions) => {
|
|
48
|
+
if (formatOptions) {
|
|
49
|
+
return undefined === timeZoneOffset ? date.toLocaleDateString(formatOptions.locales, formatOptions.options) :
|
|
50
|
+
adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString(formatOptions.locales, formatOptions.options);
|
|
51
|
+
}
|
|
47
52
|
return undefined === timeZoneOffset ? date.toLocaleDateString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString();
|
|
48
53
|
};
|
|
49
54
|
/**
|
|
50
55
|
* Format the time included in a date, optionally converting to time zone, if specified
|
|
51
56
|
* @param date Date object
|
|
52
57
|
* @param timeZoneOffset optional: offset from UTC to use for conversion
|
|
58
|
+
* @param formatOptions optional: allow locale and format for output Time string. If not defined current locale options are used.
|
|
53
59
|
* @returns formatted time string
|
|
54
60
|
* @public
|
|
55
61
|
*/
|
|
56
|
-
export const toTimeString = (date, timeZoneOffset) => {
|
|
62
|
+
export const toTimeString = (date, timeZoneOffset, formatOptions) => {
|
|
63
|
+
if (formatOptions) {
|
|
64
|
+
return undefined === timeZoneOffset ? date.toLocaleTimeString(formatOptions.locales, formatOptions.options) :
|
|
65
|
+
adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString(formatOptions.locales, formatOptions.options);
|
|
66
|
+
}
|
|
57
67
|
return undefined === timeZoneOffset ? date.toLocaleTimeString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString();
|
|
58
68
|
};
|
|
59
69
|
//# sourceMappingURL=DateUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateUtils.js","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;
|
|
1
|
+
{"version":3,"file":"DateUtils.js","sourceRoot":"","sources":["../../../../src/components-react/common/DateUtils.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAWH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAgB,EAAE,SAAiB;IACtE,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,iBAAiB,EAAE,GAAG,SAAS,CAAC,GAAG,KAAK,CAAC,CAAC;AAC/F,CAAC;AACD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAU,EAAE,cAAuB,EAAE,aAAiC,EAAE,EAAE;IACrG,IAAI,aAAa,EAAE;QACjB,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3G,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;KAC/G;IACD,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpI,CAAC,CAAC;AACF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAU,EAAE,cAAuB,EAAE,aAAiC,EAAE,EAAE;IACrG,IAAI,aAAa,EAAE;QACjB,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;YAC3G,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;KAC/G;IACD,OAAO,SAAS,KAAK,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAC;AACpI,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Common\r\n */\r\n\r\n/**\r\n * Define formatting options for use when component are generating a formatted date string calling `Date.toLocaleTimeString()`.\r\n * @public\r\n */\r\nexport interface DateFormatOptions {\r\n locales?: string | string[] | undefined;\r\n options?: Intl.DateTimeFormatOptions | undefined;\r\n}\r\n\r\n/**\r\n * Adjust a Date object to show time in one time zone as if it is in the local time zone.\r\n * This is useful when showing sunrise and sunset times for a project location in a different time zone\r\n * and the time displayed should appear as if the user is seeing clock in project location.\r\n * Example 1:\r\n * If you have a UTC time for London (UTC +0100) and you want to display it in Eastern-US (UTC -0400) as if you were in London.\r\n * ```ts\r\n * londonDate = new Date(\"July 22, 2018 07:22:13 +0100\");\r\n * in Eastern-US londonDate will show as '7/22/2018, 2:22:13 AM'\r\n * adjustedDate = adjustDateToTimezone(londonDate, 1*60);\r\n * in location Eastern-US adjustedDate will show as '7/22/2018, 7:22:13 AM'\r\n * ```\r\n * Example 2:\r\n * If you have a UTC time for your location (UTC -0400) and you want to display the time as if you are in Western-US (UTC -0700).\r\n * ```ts\r\n * easternDate = new Date(\"July 22, 2018 07:22:13 -0400\");\r\n * adjustedDate = adjustDateToTimezone(easternDate, -7*60);\r\n * in location Eastern-US adjustedDate will show as '7/22/2018, 7:22:13 AM'\r\n * ```\r\n *\r\n * The utcOffset must be the time in minutes between the UTC and the desired time zone at the date specified by inDateTime.\r\n * For example, if you want the time offset to New York, NY and the date is during Daylight Saving Time, utcOffset should be -240 (-4 * 60).\r\n * If the date falls during Standard Time in New York, utcOffset will be -300 (-5 * 60).\r\n *\r\n * @param inDateTime date/time at project location\r\n * @param utcOffset UTC offset in minutes\r\n * @public\r\n */\r\nexport function adjustDateToTimezone(inDateTime: Date, utcOffset: number) {\r\n return new Date(inDateTime.getTime() + (inDateTime.getTimezoneOffset() + utcOffset) * 60000);\r\n}\r\n/**\r\n * Format a date in a display string, optionally converting to time zone, if specified by timeZoneOffset\r\n * @param date Date object to format\r\n * @param timeZoneOffset optional: offset from UTC to use for conversion\r\n * @param formatOptions optional: allow locale and format for output Date string. If not defined current locale options are used.\r\n * @returns formatted date string\r\n * @public\r\n */\r\nexport const toDateString = (date: Date, timeZoneOffset?: number, formatOptions?: DateFormatOptions) => {\r\n if (formatOptions) {\r\n return undefined === timeZoneOffset ? date.toLocaleDateString(formatOptions.locales, formatOptions.options) :\r\n adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString(formatOptions.locales, formatOptions.options);\r\n }\r\n return undefined === timeZoneOffset ? date.toLocaleDateString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleDateString();\r\n};\r\n/**\r\n * Format the time included in a date, optionally converting to time zone, if specified\r\n * @param date Date object\r\n * @param timeZoneOffset optional: offset from UTC to use for conversion\r\n * @param formatOptions optional: allow locale and format for output Time string. If not defined current locale options are used.\r\n * @returns formatted time string\r\n * @public\r\n */\r\nexport const toTimeString = (date: Date, timeZoneOffset?: number, formatOptions?: DateFormatOptions) => {\r\n if (formatOptions) {\r\n return undefined === timeZoneOffset ? date.toLocaleTimeString(formatOptions.locales, formatOptions.options) :\r\n adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString(formatOptions.locales, formatOptions.options);\r\n }\r\n return undefined === timeZoneOffset ? date.toLocaleTimeString() : adjustDateToTimezone(date, timeZoneOffset).toLocaleTimeString();\r\n};\r\n\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/components-react",
|
|
3
|
-
"version": "3.3.0-dev.
|
|
3
|
+
"version": "3.3.0-dev.46",
|
|
4
4
|
"description": "iTwin.js UI complex components",
|
|
5
5
|
"main": "lib/cjs/components-react.js",
|
|
6
6
|
"module": "lib/esm/components-react.js",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"url": "http://www.bentley.com"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@itwin/appui-abstract": "^3.3.0-dev.
|
|
24
|
-
"@itwin/core-bentley": "^3.3.0-dev.
|
|
25
|
-
"@itwin/core-react": "^3.3.0-dev.
|
|
23
|
+
"@itwin/appui-abstract": "^3.3.0-dev.46",
|
|
24
|
+
"@itwin/core-bentley": "^3.3.0-dev.46",
|
|
25
|
+
"@itwin/core-react": "^3.3.0-dev.46",
|
|
26
26
|
"react": "^17.0.0",
|
|
27
27
|
"react-dom": "^17.0.0"
|
|
28
28
|
},
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
32
32
|
],
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@itwin/appui-abstract": "3.3.0-dev.
|
|
35
|
-
"@itwin/build-tools": "3.3.0-dev.
|
|
36
|
-
"@itwin/core-bentley": "3.3.0-dev.
|
|
37
|
-
"@itwin/core-common": "3.3.0-dev.
|
|
38
|
-
"@itwin/core-i18n": "3.3.0-dev.
|
|
39
|
-
"@itwin/core-react": "3.3.0-dev.
|
|
40
|
-
"@itwin/eslint-plugin": "3.3.0-dev.
|
|
34
|
+
"@itwin/appui-abstract": "3.3.0-dev.46",
|
|
35
|
+
"@itwin/build-tools": "3.3.0-dev.46",
|
|
36
|
+
"@itwin/core-bentley": "3.3.0-dev.46",
|
|
37
|
+
"@itwin/core-common": "3.3.0-dev.46",
|
|
38
|
+
"@itwin/core-i18n": "3.3.0-dev.46",
|
|
39
|
+
"@itwin/core-react": "3.3.0-dev.46",
|
|
40
|
+
"@itwin/eslint-plugin": "3.3.0-dev.46",
|
|
41
41
|
"@testing-library/dom": "^8.11.2",
|
|
42
42
|
"@testing-library/react": "^12.0.0",
|
|
43
43
|
"@testing-library/react-hooks": "^7.0.2",
|