-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issues 126/cet time #126 and a few changes by #123 Reviewed-by: Anton Sidelnikov Reviewed-by: Ilia Bakhterev
- Loading branch information
1 parent
39a3fb7
commit dadc8a6
Showing
12 changed files
with
263 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const formatDateTimeWithTimeZone = (date) => { | ||
if (isNaN(date.getTime())) return 'Invalid Date'; | ||
|
||
const options = { | ||
year: 'numeric', | ||
month: 'short', | ||
day: '2-digit', | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
timeZoneName: 'short', | ||
hour12: false, | ||
}; | ||
|
||
const localDateTime = new Intl.DateTimeFormat('en-GB', options).format(date); | ||
return localDateTime.replace(/(\d{2})\/(\d{2})\/(\d{4}), (\d{2}:\d{2}) (.+)/, '$3-$2-$1 $4 $5'); | ||
}; | ||
|
||
const updateDateLabels = () => { | ||
document.querySelectorAll('.datetime').forEach((element) => { | ||
const dateTimeStr = element.textContent; | ||
const dateTimeUTC = new Date(dateTimeStr); | ||
element.textContent = formatDateTimeWithTimeZone(dateTimeUTC); | ||
}); | ||
}; | ||
|
||
updateDateLabels(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const updateDateLabel = (selectElement) => { | ||
const selectedValue = selectElement ? selectElement.value : ''; | ||
const updateDateLabelElement = document.getElementById('updateDateLabelElement'); | ||
const updateDateDiv = document.getElementById('updateDateDiv'); | ||
const updateMessageDiv = document.getElementById('updateMessageDiv'); | ||
|
||
if (updateDateLabelElement && updateDateDiv && updateMessageDiv) { | ||
switch (selectedValue) { | ||
case 'reopened': | ||
updateMessageDiv.style.display = 'block'; | ||
updateDateDiv.style.display = 'none'; | ||
break; | ||
default: | ||
updateDateLabelElement.innerText = 'Updated at:'; | ||
updateDateDiv.style.display = 'block'; | ||
updateMessageDiv.style.display = 'block'; | ||
break; | ||
case 'Choose status..': | ||
updateDateLabelElement.innerText = 'Updated at:'; | ||
updateDateDiv.style.display = 'block'; | ||
updateMessageDiv.style.display = 'block'; | ||
break; | ||
} | ||
} | ||
}; | ||
|
||
const updateMaintenanceFields = (selectElement) => { | ||
const selectedValue = selectElement ? selectElement.value : ''; | ||
const updateDateLabelElement = document.getElementById('updateDateLabelElement'); | ||
const updateDateDiv = document.getElementById('updateDateDiv'); | ||
const maintenanceStartDiv = document.getElementById('maintenanceStartDiv'); | ||
const maintenanceEndDiv = document.getElementById('maintenanceEndDiv'); | ||
const updateMessageDiv = document.getElementById('updateMessageDiv'); | ||
|
||
|
||
if (maintenanceStartDiv && maintenanceEndDiv && updateMessageDiv) { | ||
switch (selectedValue) { | ||
case 'modified': | ||
maintenanceStartDiv.style.display = 'block'; | ||
maintenanceEndDiv.style.display = 'block'; | ||
updateDateDiv.style.display = 'none'; | ||
break; | ||
case 'completed': | ||
maintenanceEndDiv.style.display = 'none'; | ||
maintenanceStartDiv.style.display = 'none'; | ||
updateDateDiv.style.display = 'block'; | ||
break; | ||
default: | ||
maintenanceStartDiv.style.display = 'none'; | ||
maintenanceEndDiv.style.display = 'none'; | ||
updateDateDiv.style.display = 'block'; | ||
updateDateLabelElement.innerText = 'Updated at:'; | ||
break; | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const timezoneField = document.getElementById('timezone'); | ||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone || 'UTC'; | ||
if (timezoneField) { | ||
timezoneField.value = timezone; | ||
|
||
} | ||
|
||
const date = new Date(); | ||
const timezoneName = new Intl.DateTimeFormat('en-GB', { | ||
timeZone: timezone, | ||
timeZoneName: 'short' | ||
}).formatToParts(date).find(part => part.type === 'timeZoneName').value; | ||
|
||
const timezoneInfoElements = document.querySelectorAll('.timezone-info'); | ||
timezoneInfoElements.forEach(element => { | ||
element.textContent = `${timezoneName}`; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.