Skip to content

Commit

Permalink
Fix meeting planner and storage tank samples
Browse files Browse the repository at this point in the history
  • Loading branch information
justingrant committed Jul 1, 2020
1 parent 20fe4cd commit aa5ba70
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions docs/cookbook/meetingPlanner.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Display local time zone and three others
const now = Temporal.now.localDateTime();
const timeZones = [
{ name: 'Here', tz: now.timeZone() },
{ name: 'Here', tz: Temporal.now.timeZone() },
{ name: 'New York', tz: Temporal.TimeZone.from('America/New_York') },
{ name: 'London', tz: Temporal.TimeZone.from('Europe/London') },
{ name: 'Tokyo', tz: Temporal.TimeZone.from('Asia/Tokyo') }
Expand All @@ -12,18 +12,19 @@ const startTime = now.with(Temporal.Time.from('00:00')); // midnight

// Build the table
const table = document.getElementById('meeting-planner');
timeZones.forEach(({ name }) => {
timeZones.forEach(({ name, tz }) => {
const row = document.createElement('tr');

const title = document.createElement('td');
const offset = now.with({ timeZone: name }).timeZoneOffsetString;
title.textContent = `${name} (UTC${offset})`;
const nowThisTz = now.with({ timeZone: tz });
title.textContent = `${name} (UTC${nowThisTz.timeZoneOffsetString})`;
row.appendChild(title);
const startThisTz = startTime.with({ timeZone: tz });

for (let hours = 0; hours < 24; hours++) {
const cell = document.createElement('td');

const ldt = startTime.plus({ hours });
const ldt = startThisTz.plus({ hours });
cell.className = `time-${ldt.hour}`;

// Highlight the current hour in each row
Expand Down
2 changes: 1 addition & 1 deletion docs/cookbook/storageTank.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
const tankMidnight = Temporal.now
.localDateTime()
.with({ timeZone: 'Europe/Stockholm', ...Temporal.Time.from('00:00').getFields() });
const atOrAfterMidnight = (x) => Temporal.Absolute.compare(x, tankMidnight) >= 0;
const atOrAfterMidnight = (x) => Temporal.Absolute.compare(x, tankMidnight.absolute) >= 0;
const dataStartIndex = tankDataX.findIndex(atOrAfterMidnight);
const labelFormatter = new Intl.DateTimeFormat(undefined, {
weekday: 'short',
Expand Down

0 comments on commit aa5ba70

Please sign in to comment.