v0.11.3 fixed timezone issue
This commit is contained in:
@@ -16,13 +16,35 @@ const SHORT_MONTHS= ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct'
|
||||
function fmtDate(d) { return `${d.getDate()} ${SHORT_MONTHS[d.getMonth()]} ${d.getFullYear()}`; }
|
||||
function fmtTime(iso) { if(!iso) return ''; const d=new Date(iso); return d.toLocaleTimeString([],{hour:'2-digit',minute:'2-digit'}); }
|
||||
function fmtRange(s,e) { return `${fmtTime(s)} – ${fmtTime(e)}`; }
|
||||
function toDateIn(iso) { return iso?iso.slice(0,10):''; }
|
||||
function toTimeIn(iso) { if(!iso) return ''; const d=new Date(iso); const h=String(d.getHours()).padStart(2,'0'), m=d.getMinutes()<30?'00':'30'; return `${h}:${m}`; }
|
||||
function buildISO(d,t) { return d&&t?`${d}T${t}:00`:''; }
|
||||
function addHours(iso,h){
|
||||
const d=new Date(iso); d.setMinutes(d.getMinutes()+h*60);
|
||||
// Return local datetime string (YYYY-MM-DDTHH:MM:SS) — NOT toISOString() which shifts to UTC
|
||||
const pad=n=>String(n).padStart(2,'0');
|
||||
// Convert a UTC ISO string (from Postgres TIMESTAMPTZ) to local YYYY-MM-DD for <input type="date">
|
||||
function toDateIn(iso) {
|
||||
if (!iso) return '';
|
||||
const d = new Date(iso);
|
||||
const pad = n => String(n).padStart(2,'0');
|
||||
return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}`;
|
||||
}
|
||||
// Convert a UTC ISO string to local HH:MM for <input type="time">, snapped to :00 or :30
|
||||
function toTimeIn(iso) {
|
||||
if (!iso) return '';
|
||||
const d = new Date(iso);
|
||||
const h = String(d.getHours()).padStart(2,'0');
|
||||
const m = d.getMinutes() < 30 ? '00' : '30';
|
||||
return `${h}:${m}`;
|
||||
}
|
||||
// Build an ISO string with local timezone offset so Postgres stores the right UTC value
|
||||
function buildISO(date, time) {
|
||||
if (!date || !time) return '';
|
||||
// Parse as local datetime then get offset-aware ISO string
|
||||
const d = new Date(`${date}T${time}:00`);
|
||||
const pad = n => String(n).padStart(2,'0');
|
||||
const off = -d.getTimezoneOffset();
|
||||
const sign = off >= 0 ? '+' : '-';
|
||||
const abs = Math.abs(off);
|
||||
return `${date}T${time}:00${sign}${pad(Math.floor(abs/60))}:${pad(abs%60)}`;
|
||||
}
|
||||
function addHours(iso, h) {
|
||||
const d = new Date(iso); d.setMinutes(d.getMinutes() + h * 60);
|
||||
const pad = n => String(n).padStart(2,'0');
|
||||
return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:00`;
|
||||
}
|
||||
function sameDay(a,b) { return a.getFullYear()===b.getFullYear()&&a.getMonth()===b.getMonth()&&a.getDate()===b.getDate(); }
|
||||
@@ -396,7 +418,7 @@ function EventForm({ event, userGroups, eventTypes, selectedDate, onSave, onCanc
|
||||
if(groupsRequired&&grps.size===0) return toast('Select at least one group for availability tracking','error');
|
||||
setSaving(true);
|
||||
try{
|
||||
const body={title:title.trim(),eventTypeId:typeId||null,startAt:allDay?`${sd}T00:00:00`:buildISO(sd,st),endAt:allDay?`${ed}T23:59:59`:buildISO(ed,et),allDay,location:loc,description:desc,isPublic:pub,trackAvailability:track,userGroupIds:[...grps],recurrenceRule:recRule||null};
|
||||
const body={title:title.trim(),eventTypeId:typeId||null,startAt:allDay?buildISO(sd,'00:00'):buildISO(sd,st),endAt:allDay?buildISO(ed,'23:59'):buildISO(ed,et),allDay,location:loc,description:desc,isPublic:pub,trackAvailability:track,userGroupIds:[...grps],recurrenceRule:recRule||null};
|
||||
let scope='this';
|
||||
if(event && event.recurrence_rule?.freq) {
|
||||
const choice = window.confirm('This is a recurring event.\n\nOK = Update this and all future occurrences\nCancel = Update this event only');
|
||||
|
||||
Reference in New Issue
Block a user