@ascentgl/ads-ui 0.0.66 → 0.0.67
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.
|
@@ -6608,25 +6608,38 @@ class AdsTimeFieldComponent extends AdsInputDropdownComponent {
|
|
|
6608
6608
|
onBlurUpdateTime() {
|
|
6609
6609
|
let timeValue = this.valueControl.value;
|
|
6610
6610
|
if (timeValue) {
|
|
6611
|
-
//
|
|
6611
|
+
// Handle 3-digit input
|
|
6612
6612
|
if (timeValue.length === 3) {
|
|
6613
|
-
|
|
6614
|
-
|
|
6613
|
+
let hours = parseInt(timeValue.slice(0, 2), 10);
|
|
6614
|
+
let minutes = timeValue.slice(2);
|
|
6615
|
+
// If the first two digits form a valid hour (00-23), treat as HHM → HH:MM
|
|
6616
|
+
if (hours >= 0 && hours <= 23) {
|
|
6617
|
+
timeValue = `${hours.toString().padStart(2, '0')}:0${minutes}`;
|
|
6618
|
+
}
|
|
6619
|
+
else {
|
|
6620
|
+
// Otherwise, treat as HMM → HH:MM
|
|
6621
|
+
hours = parseInt(timeValue.charAt(0), 10);
|
|
6622
|
+
minutes = timeValue.slice(1);
|
|
6623
|
+
timeValue = `${hours.toString().padStart(2, '0')}:${minutes}`;
|
|
6624
|
+
}
|
|
6615
6625
|
}
|
|
6626
|
+
// Handle 4-digit input without a colon (e.g., "2200" → "22:00")
|
|
6627
|
+
else if (timeValue.length === 4 && !timeValue.includes(':')) {
|
|
6628
|
+
let hours = parseInt(timeValue.slice(0, 2), 10);
|
|
6629
|
+
const minutes = timeValue.slice(2);
|
|
6630
|
+
// Adjust hours if greater than 23
|
|
6631
|
+
if (hours >= 24) {
|
|
6632
|
+
hours -= 24;
|
|
6633
|
+
}
|
|
6634
|
+
timeValue = `${hours.toString().padStart(2, '0')}:${minutes}`;
|
|
6635
|
+
}
|
|
6636
|
+
// Handle 4-character input with one-minute digit (e.g., "22:2" → "22:20")
|
|
6616
6637
|
else if (timeValue.length === 4 && timeValue.includes(':')) {
|
|
6617
|
-
// Add a trailing "0" to minutes if only one digit is present
|
|
6618
6638
|
const [hours, minutes] = timeValue.split(':');
|
|
6619
6639
|
if (minutes.length === 1) {
|
|
6620
6640
|
timeValue = `${hours}:${minutes}0`;
|
|
6621
6641
|
}
|
|
6622
6642
|
}
|
|
6623
|
-
else if (timeValue.length === 4) {
|
|
6624
|
-
// If the value is 4 digits long, treat it as HHMM and split it into hours and minutes
|
|
6625
|
-
const hours = timeValue.slice(0, 2); // First two digits as hours
|
|
6626
|
-
const minutes = timeValue.slice(2); // Last two digits as minutes
|
|
6627
|
-
// Ensure the minutes are 2 digits
|
|
6628
|
-
timeValue = `${hours}:${minutes}`;
|
|
6629
|
-
}
|
|
6630
6643
|
// Update the form control value in HH:mm format
|
|
6631
6644
|
this.valueControl.setValue(timeValue, { emitEvent: false });
|
|
6632
6645
|
}
|