Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions site/themes/s2b_hugo_theme/assets/js/cal/addevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@
var $form = $('#event-entry');
$.extend(previewEvent, shiftEvent, eventFromForm());

previewEvent['displayStartTime'] = dayjs(previewEvent['time'], 'hh:mm:ss').format('h:mm A');
previewEvent['displayStartTime'] = dayjs(previewEvent['time'], 'HH:mm:ss').format('h:mm A');
if ( previewEvent['eventduration'] ){
var endTime = dayjs(previewEvent['time'], 'hh:mm:ss')
var endTime = dayjs(previewEvent['time'], 'HH:mm:ss')
.add(previewEvent['eventduration'], 'minutes')
.format('HH:mm');
previewEvent['endtime'] = endTime; // e.g. 18:00
Expand Down
25 changes: 17 additions & 8 deletions site/themes/s2b_hugo_theme/assets/js/cal/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,26 @@
return Mustache.render(dateStatusesTemplate, {dateStatuses});
}

// Return the current date in Pacific time as a YYYY-MM-DD string.
// Using Intl.DateTimeFormat ensures correctness regardless of the browser's local timezone.
function getPacificToday() {
return new Date().toLocaleDateString('en-CA', {
timeZone: 'America/Los_Angeles',
year: 'numeric',
month: '2-digit',
day: '2-digit'
});
}

function isToday(date) {
return dayjs().isSame(date, 'day');
return dayjs(date).format('YYYY-MM-DD') === getPacificToday();
}

// return the utc YYYY-MM-DD string of the passed date
// note: 'date' is sometimes a utc string, or a dayjs object.
// return the YYYY-MM-DD string of the passed date
// note: 'date' is sometimes a string, or a dayjs object.
// see also: main.js viewEvents()
function toUtcString(date) {
// tbd: does the server actually handle dates as utc?
// i believe times ( ex. start times ) are assumed local.
return dayjs(date).utc().format('YYYY-MM-DD');
function toUtcString(date) {
return dayjs(date).format('YYYY-MM-DD');
}

function isSelected(date) {
Expand Down Expand Up @@ -237,7 +246,7 @@
// fix: should this scroll the first scheduled day into view
// ( ex. when editing existing events )
function initDatePicker() {
const now = dayjs();
const now = dayjs(getPacificToday());
earliestMonth = now;
latestMonth = now.add(1, 'month');

Expand Down
4 changes: 2 additions & 2 deletions site/themes/s2b_hugo_theme/assets/js/cal/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ $(document).ready(function() {
mustacheData.dates.push(groupedByDate[date]);
}

value.displayStartTime = dayjs(value.time, 'hh:mm:ss').format('h:mm A');
value.displayStartTime = dayjs(value.time, 'HH:mm:ss').format('h:mm A');
value.displayDate = dayjs(value.date).format('ddd, MMM D, YYYY');
if (value.endtime) {
value.displayEndTime = dayjs(value.endtime, 'hh:mm:ss').format('h:mm A');
value.displayEndTime = dayjs(value.endtime, 'HH:mm:ss').format('h:mm A');
}

value.audienceLabel = container.getAudienceLabel(value.audience);
Expand Down