chore: add AGENTS.md with build, lint, test commands and style guidelines

This commit is contained in:
DiTus
2026-03-18 21:17:43 +01:00
parent e98c25efc4
commit 509f8033fa
32 changed files with 10087 additions and 133 deletions

76
js/config/timezone.js Normal file
View File

@ -0,0 +1,76 @@
const TimezoneConfig = {
timezone: localStorage.getItem('timezone') || 'Europe/Warsaw',
availableTimezones: [
{ value: 'UTC', label: 'UTC', offset: 0 },
{ value: 'Europe/London', label: 'London (GMT/BST)', offset: 0 },
{ value: 'Europe/Paris', label: 'Central Europe (CET/CEST)', offset: 1 },
{ value: 'Europe/Warsaw', label: 'Warsaw (CET/CEST)', offset: 1 },
{ value: 'America/New_York', label: 'New York (EST/EDT)', offset: -5 },
{ value: 'America/Chicago', label: 'Chicago (CST/CDT)', offset: -6 },
{ value: 'America/Los_Angeles', label: 'Los Angeles (PST/PDT)', offset: -8 },
{ value: 'Asia/Tokyo', label: 'Tokyo (JST)', offset: 9 },
{ value: 'Asia/Shanghai', label: 'Shanghai (CST)', offset: 8 },
{ value: 'Australia/Sydney', label: 'Sydney (AEST/AEDT)', offset: 10 },
],
setTimezone(tz) {
this.timezone = tz;
localStorage.setItem('timezone', tz);
document.dispatchEvent(new CustomEvent('timezone-changed', { detail: tz }));
},
getTimezone() {
return this.timezone;
},
getOffsetHours(tz = this.timezone) {
const now = new Date();
const tzDate = new Date(now.toLocaleString('en-US', { timeZone: tz }));
const utcDate = new Date(now.toLocaleString('en-US', { timeZone: 'UTC' }));
return (tzDate - utcDate) / 3600000;
},
formatDate(timestamp) {
const date = new Date(timestamp);
const tz = this.timezone;
const options = {
timeZone: tz,
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', second: '2-digit',
hour12: false
};
const formatter = new Intl.DateTimeFormat('en-GB', options);
const parts = formatter.formatToParts(date);
const get = (type) => parts.find(p => p.type === type).value;
return `${get('day')}/${get('month')}/${get('year')} ${get('hour')}:${get('minute')}`;
},
formatTickMark(timestamp) {
const date = new Date(timestamp * 1000);
const tz = this.timezone;
const options = {
timeZone: tz,
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit',
hour12: false
};
const formatter = new Intl.DateTimeFormat('en-GB', options);
const parts = formatter.formatToParts(date);
const get = (type) => parts.find(p => p.type === type).value;
// If it's exactly midnight, just show the date, otherwise show time too
const isMidnight = get('hour') === '00' && get('minute') === '00';
if (isMidnight) {
return `${get('day')}/${get('month')}/${get('year')}`;
}
return `${get('day')}/${get('month')} ${get('hour')}:${get('minute')}`;
}
};
export { TimezoneConfig };