diff --git a/package-lock.json b/package-lock.json
index a4cbbfa..030df5a 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -20,7 +20,7 @@
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.3",
- "@types/google.maps": "~3.53.6",
+ "@types/google.maps": "~3.55.6",
"@types/jasmine": "^4.3.6",
"@types/react": "^18.2.24",
"@web/test-runner": "^0.17.1",
@@ -610,9 +610,9 @@
}
},
"node_modules/@types/google.maps": {
- "version": "3.53.6",
- "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.53.6.tgz",
- "integrity": "sha512-zDU8c7K0YR1Ob7Wn0qCSQvICIuxilZH9KFIDHK6JO/5QzqEMv8e4+9bmyoDEktA9vPNmwP++zzg65h9y53iZ6Q==",
+ "version": "3.55.6",
+ "resolved": "https://registry.npmjs.org/@types/google.maps/-/google.maps-3.55.6.tgz",
+ "integrity": "sha512-RDtveRsejIi7KRnahz+PE1+Uo+6axr98Susjn/7DxNPPej/T0sMMJfnwm3NcQgvVDWvixWCMOn2Sfukq5UVF2g==",
"dev": true
},
"node_modules/@types/http-assert": {
diff --git a/package.json b/package.json
index 6e0a1a3..0e59241 100644
--- a/package.json
+++ b/package.json
@@ -76,7 +76,7 @@
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "^0.4.3",
- "@types/google.maps": "~3.53.6",
+ "@types/google.maps": "~3.55.6",
"@types/jasmine": "^4.3.6",
"@types/react": "^18.2.24",
"@web/test-runner": "^0.17.1",
diff --git a/src/place_building_blocks/place_field_boolean/place_field_boolean.ts b/src/place_building_blocks/place_field_boolean/place_field_boolean.ts
index 000075d..c430aa5 100644
--- a/src/place_building_blocks/place_field_boolean/place_field_boolean.ts
+++ b/src/place_building_blocks/place_field_boolean/place_field_boolean.ts
@@ -195,7 +195,7 @@ export class PlaceFieldBoolean extends PlaceDataConsumer {
case 'isOpen()':
return [
'businessStatus',
- 'openingHours',
+ 'regularOpeningHours',
'utcOffsetMinutes',
];
case 'hasWheelchairAccessibleEntrance':
diff --git a/src/place_building_blocks/place_field_boolean/place_field_boolean_test.ts b/src/place_building_blocks/place_field_boolean/place_field_boolean_test.ts
index 4bd93a4..01f1637 100644
--- a/src/place_building_blocks/place_field_boolean/place_field_boolean_test.ts
+++ b/src/place_building_blocks/place_field_boolean/place_field_boolean_test.ts
@@ -67,7 +67,7 @@ describe('place field boolean test', () => {
servesWine: true,
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
- openingHours: {periods: [], weekdayDescriptions: []},
+ regularOpeningHours: {periods: [], weekdayDescriptions: []},
utcOffsetMinutes: 0,
isOpen: async () => true,
});
@@ -102,7 +102,7 @@ describe('place field boolean test', () => {
servesWine: false,
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
- openingHours: {periods: [], weekdayDescriptions: []},
+ regularOpeningHours: {periods: [], weekdayDescriptions: []},
utcOffsetMinutes: 0,
isOpen: async () => false,
});
@@ -137,7 +137,7 @@ describe('place field boolean test', () => {
servesWine: null,
businessStatus: null,
- openingHours: null,
+ regularOpeningHours: null,
utcOffsetMinutes: null,
isOpen: async () => undefined,
});
@@ -244,7 +244,7 @@ describe('place field boolean test', () => {
const openPlace = makeFakePlace({
id: '1234567890',
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
- openingHours: {periods: [], weekdayDescriptions: []},
+ regularOpeningHours: {periods: [], weekdayDescriptions: []},
utcOffsetMinutes: 0,
isOpen: async () => true,
});
@@ -274,7 +274,7 @@ describe('place field boolean test', () => {
const isOpenSpy = jasmine.createSpy('isOpen');
const noBusinessStatusPlace = makeFakePlace({
id: '1234567890',
- openingHours: {periods: [], weekdayDescriptions: []},
+ regularOpeningHours: {periods: [], weekdayDescriptions: []},
isOpen: isOpenSpy,
});
const noOpeningHoursPlace = makeFakePlace({
@@ -286,7 +286,7 @@ describe('place field boolean test', () => {
const noUtcOffsetPlace = makeFakePlace({
id: '1234567890',
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
- openingHours: {periods: [], weekdayDescriptions: []},
+ regularOpeningHours: {periods: [], weekdayDescriptions: []},
isOpen: isOpenSpy,
});
@@ -308,7 +308,7 @@ describe('place field boolean test', () => {
const place = makeFakePlace({
id: '1234567890',
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
- openingHours: {periods: [], weekdayDescriptions: []},
+ regularOpeningHours: {periods: [], weekdayDescriptions: []},
utcOffsetMinutes: 0,
isOpen: isOpenSpy,
});
@@ -347,7 +347,7 @@ describe('place field boolean test', () => {
const place = makeFakePlace({
id: '1234567890',
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
- openingHours: {periods: [], weekdayDescriptions: []},
+ regularOpeningHours: {periods: [], weekdayDescriptions: []},
utcOffsetMinutes: 0,
});
const [el] = await prepareState(html`
diff --git a/src/place_building_blocks/place_opening_hours/place_opening_hours.ts b/src/place_building_blocks/place_opening_hours/place_opening_hours.ts
index 1dc3cf4..3cff018 100644
--- a/src/place_building_blocks/place_opening_hours/place_opening_hours.ts
+++ b/src/place_building_blocks/place_opening_hours/place_opening_hours.ts
@@ -116,7 +116,7 @@ export class PlaceOpeningHours extends PlaceDataConsumer {
if (!place) return nothing;
// If opening hours data is missing, try to render business status instead.
- if (!place.openingHours) {
+ if (!place.regularOpeningHours) {
if (place.businessStatus === 'OPERATIONAL') return nothing;
return html`
@@ -125,6 +125,7 @@ export class PlaceOpeningHours extends PlaceDataConsumer {
`;
}
+ const {weekdayDescriptions} = place.regularOpeningHours;
// if UTC offset data is missing, omit opening status from the summary.
let summary;
@@ -161,7 +162,7 @@ export class PlaceOpeningHours extends PlaceDataConsumer {
role="region"
>
- ${map(place.openingHours.weekdayDescriptions, (description) => html`
+ ${map(weekdayDescriptions, (description) => html`
- ${description}
`)}
@@ -171,14 +172,14 @@ export class PlaceOpeningHours extends PlaceDataConsumer {
/** @ignore */
getRequiredFields(): Array {
- return ['businessStatus', 'openingHours', 'utcOffsetMinutes'];
+ return ['businessStatus', 'regularOpeningHours', 'utcOffsetMinutes'];
}
protected override placeHasData(place: Place): boolean {
- if (place.businessStatus === 'OPERATIONAL' && !place.openingHours) {
+ if (place.businessStatus === 'OPERATIONAL' && !place.regularOpeningHours) {
return false;
}
- return !!(place.businessStatus || place.openingHours);
+ return !!(place.businessStatus || place.regularOpeningHours);
}
private getOpenSummaryContent(place: Place) {
diff --git a/src/place_building_blocks/place_opening_hours/place_opening_hours_test.ts b/src/place_building_blocks/place_opening_hours/place_opening_hours_test.ts
index cc7dd5e..2eb125c 100644
--- a/src/place_building_blocks/place_opening_hours/place_opening_hours_test.ts
+++ b/src/place_building_blocks/place_opening_hours/place_opening_hours_test.ts
@@ -21,7 +21,7 @@ import {PlaceOpeningHours} from './place_opening_hours.js';
const FAKE_PLACE_PROPS: Pick&Partial = {
id: '1234567890',
businessStatus: 'OPERATIONAL' as google.maps.places.BusinessStatus,
- openingHours: {
+ regularOpeningHours: {
periods: [
{
open: {day: 0, hour: 10, minute: 0},
@@ -83,7 +83,7 @@ describe('PlaceOpeningHours', () => {
it('renders nothing when place is operational but opening hours is missing',
async () => {
const place =
- makeFakePlace({...FAKE_PLACE_PROPS, openingHours: undefined});
+ makeFakePlace({...FAKE_PLACE_PROPS, regularOpeningHours: undefined});
const el = await prepareState({place});
expect(el.renderRoot.textContent).toBe('');
@@ -93,7 +93,7 @@ describe('PlaceOpeningHours', () => {
const place = makeFakePlace({
...FAKE_PLACE_PROPS,
businessStatus: 'CLOSED_TEMPORARILY' as google.maps.places.BusinessStatus,
- openingHours: undefined,
+ regularOpeningHours: undefined,
});
const el = await prepareState({place});
@@ -143,7 +143,7 @@ describe('PlaceOpeningHours', () => {
it('labels place as open 24 hours when close time is null', async () => {
const place = makeFakePlace({
...FAKE_PLACE_PROPS,
- openingHours: {
+ regularOpeningHours: {
periods: [
{
open: {day: 0, hour: 0, minute: 0},
@@ -161,7 +161,7 @@ describe('PlaceOpeningHours', () => {
it('omits closing time when data is insufficient', async () => {
const place = makeFakePlace({
...FAKE_PLACE_PROPS,
- openingHours: {
+ regularOpeningHours: {
periods: [],
weekdayDescriptions: [],
},
@@ -249,7 +249,8 @@ describe('PlaceOpeningHours', () => {
const details = el.renderRoot.querySelector('#details');
expect(details?.textContent)
.toHaveNormalizedText(
- FAKE_PLACE_PROPS.openingHours!.weekdayDescriptions.join(' '));
+ FAKE_PLACE_PROPS.regularOpeningHours!.weekdayDescriptions.join(
+ ' '));
});
it('polls for updates when a Place is set', async () => {
diff --git a/src/testing/fake_place.ts b/src/testing/fake_place.ts
index 67ec204..af241cb 100644
--- a/src/testing/fake_place.ts
+++ b/src/testing/fake_place.ts
@@ -80,7 +80,7 @@ export const SAMPLE_FAKE_PLACE = makeFakePlace({
internationalPhoneNumber: '+1 234-567-8910',
location: new FakeLatLng(1, 2),
nationalPhoneNumber: '(234) 567-8910',
- openingHours: {
+ regularOpeningHours: {
periods: [
{
close: {day: 0, hour: 18, minute: 0},
diff --git a/src/utils/opening_hours.ts b/src/utils/opening_hours.ts
index 35d3229..36b372a 100644
--- a/src/utils/opening_hours.ts
+++ b/src/utils/opening_hours.ts
@@ -172,14 +172,14 @@ interface UpcomingCloseTimeResult {
*/
export function getUpcomingCloseTime(
place: Place, now = new Date()): UpcomingCloseTimeResult {
- if (!place.openingHours || place.utcOffsetMinutes == null) {
+ if (!place.regularOpeningHours || place.utcOffsetMinutes == null) {
return {status: NextCloseTimeStatus.UNKNOWN};
- } else if (isPlaceAlwaysOpen(place.openingHours)) {
+ } else if (isPlaceAlwaysOpen(place.regularOpeningHours)) {
return {status: NextCloseTimeStatus.ALWAYS_OPEN};
}
const currentPeriod =
- getCurrentPeriod(place.openingHours, place.utcOffsetMinutes, now);
+ getCurrentPeriod(place.regularOpeningHours, place.utcOffsetMinutes, now);
if (!currentPeriod.period) {
return {status: NextCloseTimeStatus.NOT_OPEN_NOW};
} else if (!currentPeriod.closeDate) {
@@ -220,9 +220,9 @@ interface UpcomingOpenTimeResult {
*/
export function getUpcomingOpenTime(
place: Place, now = new Date()): UpcomingOpenTimeResult {
- if (!place.openingHours || place.utcOffsetMinutes == null) {
+ if (!place.regularOpeningHours || place.utcOffsetMinutes == null) {
return {status: NextOpenTimeStatus.UNKNOWN};
- } else if (isPlaceAlwaysOpen(place.openingHours)) {
+ } else if (isPlaceAlwaysOpen(place.regularOpeningHours)) {
return {status: NextOpenTimeStatus.ALREADY_OPEN};
}
@@ -232,7 +232,7 @@ export function getUpcomingOpenTime(
status: NextOpenTimeStatus.NEVER_OPEN,
};
let closestOpenInterval = Infinity;
- for (const period of place.openingHours.periods) {
+ for (const period of place.regularOpeningHours.periods) {
const openDate = getPointDate(period.open, lastSundayStart);
if (!period.close) {
return {status: NextOpenTimeStatus.ALREADY_OPEN};
@@ -264,12 +264,12 @@ export function getUpcomingOpenTime(
* Temporary (until Place is GA) replacement for the built-in isOpen() method.
*/
export function isOpen(place: Place, now = new Date()): boolean|undefined {
- if (!place.openingHours || place.utcOffsetMinutes == null) {
+ if (!place.regularOpeningHours || place.utcOffsetMinutes == null) {
return undefined;
- } else if (isPlaceAlwaysOpen(place.openingHours)) {
+ } else if (isPlaceAlwaysOpen(place.regularOpeningHours)) {
return true;
}
const {period} =
- getCurrentPeriod(place.openingHours, place.utcOffsetMinutes, now);
+ getCurrentPeriod(place.regularOpeningHours, place.utcOffsetMinutes, now);
return !!period;
}
\ No newline at end of file
diff --git a/src/utils/opening_hours_test.ts b/src/utils/opening_hours_test.ts
index 6bcc934..4597c2a 100644
--- a/src/utils/opening_hours_test.ts
+++ b/src/utils/opening_hours_test.ts
@@ -101,8 +101,8 @@ describe('Opening hours utilities', () => {
describe('getUpcomingCloseTime', () => {
it('returns unknown when there isn\'t enough information', async () => {
const utcOffsetMinutes = NYC_OFFSET;
- const place =
- makeFakePlace({id: '123', openingHours: undefined, utcOffsetMinutes});
+ const place = makeFakePlace(
+ {id: '123', regularOpeningHours: undefined, utcOffsetMinutes});
expect(getUpcomingCloseTime(place, new Date())).toEqual({
status: NextCloseTimeStatus.UNKNOWN
@@ -110,8 +110,11 @@ describe('Opening hours utilities', () => {
});
it('returns a status when the place is always open', () => {
- const place = makeFakePlace(
- {id: '123', openingHours: ALWAYS_OPEN_HOURS, utcOffsetMinutes: 0});
+ const place = makeFakePlace({
+ id: '123',
+ regularOpeningHours: ALWAYS_OPEN_HOURS,
+ utcOffsetMinutes: 0,
+ });
expect(getUpcomingCloseTime(place, new Date())).toEqual({
status: NextCloseTimeStatus.ALWAYS_OPEN
@@ -123,7 +126,8 @@ describe('Opening hours utilities', () => {
const monday8AmSf = makeDateInLocale('2023-04-10T08:00', SF_OFFSET);
const place = makeFakePlace({
id: '123',
- openingHours: {periods: [mondayNineToFive], weekdayDescriptions: []},
+ regularOpeningHours:
+ {periods: [mondayNineToFive], weekdayDescriptions: []},
utcOffsetMinutes: SF_OFFSET
});
@@ -138,7 +142,8 @@ describe('Opening hours utilities', () => {
const monday4PmSf = makeDateInLocale('2023-04-10T16:00', SF_OFFSET);
const place = makeFakePlace({
id: '123',
- openingHours: {periods: [mondayNineToFive], weekdayDescriptions: []},
+ regularOpeningHours:
+ {periods: [mondayNineToFive], weekdayDescriptions: []},
utcOffsetMinutes: NYC_OFFSET
});
@@ -149,7 +154,7 @@ describe('Opening hours utilities', () => {
it('returns a closing time for status for a Place closing soon', () => {
const thursday3PmSf = makeDateInLocale('2023-04-13T15:00', SF_OFFSET);
- const openingHours: OpeningHours = {
+ const regularOpeningHours: OpeningHours = {
periods: [
makePeriod(WED, 9, WED, 17), // Wed 9am - 5pm
makePeriod(THU, 9, THU, 17), // Thurs 9am - 5pm
@@ -157,12 +162,12 @@ describe('Opening hours utilities', () => {
],
weekdayDescriptions: []
};
- const place =
- makeFakePlace({id: '123', openingHours, utcOffsetMinutes: SF_OFFSET});
+ const place = makeFakePlace(
+ {id: '123', regularOpeningHours, utcOffsetMinutes: SF_OFFSET});
expect(getUpcomingCloseTime(place, thursday3PmSf)).toEqual({
status: NextCloseTimeStatus.WILL_CLOSE,
- closePoint: openingHours.periods[1].close!,
+ closePoint: regularOpeningHours.periods[1].close!,
closeDate: makeDateInLocale('2023-04-13T17:00', SF_OFFSET) // 5pm Thu
});
});
@@ -170,18 +175,18 @@ describe('Opening hours utilities', () => {
it('returns a closing time for a Place closing in over 24 hours from now',
() => {
const monday1pmSf = makeDateInLocale('2023-04-10T13:00', SF_OFFSET);
- const openingHours: OpeningHours = {
+ const regularOpeningHours: OpeningHours = {
periods: [
makePeriod(MON, 9, FRI, 17), // Mon 9am - Fri 5pm
],
weekdayDescriptions: []
};
const place = makeFakePlace(
- {id: '123', openingHours, utcOffsetMinutes: SF_OFFSET});
+ {id: '123', regularOpeningHours, utcOffsetMinutes: SF_OFFSET});
expect(getUpcomingCloseTime(place, monday1pmSf)).toEqual({
status: NextCloseTimeStatus.WILL_CLOSE,
- closePoint: openingHours.periods[0].close!,
+ closePoint: regularOpeningHours.periods[0].close!,
closeDate:
makeDateInLocale('2023-04-14T17:00', SF_OFFSET) // 5pm Fri
});
@@ -190,7 +195,7 @@ describe('Opening hours utilities', () => {
it('handles a period which wraps the week', () => {
// Sequence is (week start) -> (now) -> (period end) -> (period start)
const monday8amSf = makeDateInLocale('2023-04-10T08:00', SF_OFFSET);
- const openingHours: OpeningHours = {
+ const regularOpeningHours: OpeningHours = {
periods: [
makePeriod(WED, 9, WED, 17), // Wed 9am - 5pm
makePeriod(THU, 9, THU, 17), // Thurs 9am - 5pm
@@ -198,12 +203,12 @@ describe('Opening hours utilities', () => {
],
weekdayDescriptions: []
};
- const place =
- makeFakePlace({id: '123', openingHours, utcOffsetMinutes: SF_OFFSET});
+ const place = makeFakePlace(
+ {id: '123', regularOpeningHours, utcOffsetMinutes: SF_OFFSET});
expect(getUpcomingCloseTime(place, monday8amSf)).toEqual({
status: NextCloseTimeStatus.WILL_CLOSE,
- closePoint: openingHours.periods[2].close!,
+ closePoint: regularOpeningHours.periods[2].close!,
closeDate: makeDateInLocale('2023-04-10T09:00', SF_OFFSET) // 9am Mon
});
});
@@ -211,7 +216,7 @@ describe('Opening hours utilities', () => {
it('handles a period which wraps the week in the other direction', () => {
// Sequence is (week start) -> (period end) -> (period start) -> (now)
const saturday11pmSf = makeDateInLocale('2023-04-15T23:00', SF_OFFSET);
- const openingHours: OpeningHours = {
+ const regularOpeningHours: OpeningHours = {
periods: [
makePeriod(WED, 9, WED, 17), // Wed 9am - 5pm
makePeriod(THU, 9, THU, 17), // Thurs 9am - 5pm
@@ -219,12 +224,12 @@ describe('Opening hours utilities', () => {
],
weekdayDescriptions: []
};
- const place =
- makeFakePlace({id: '123', openingHours, utcOffsetMinutes: SF_OFFSET});
+ const place = makeFakePlace(
+ {id: '123', regularOpeningHours, utcOffsetMinutes: SF_OFFSET});
expect(getUpcomingCloseTime(place, saturday11pmSf)).toEqual({
status: NextCloseTimeStatus.WILL_CLOSE,
- closePoint: openingHours.periods[2].close!,
+ closePoint: regularOpeningHours.periods[2].close!,
closeDate: makeDateInLocale('2023-04-16T09:00', SF_OFFSET) // 9am Sun
});
});
@@ -234,7 +239,7 @@ describe('Opening hours utilities', () => {
it('returns a status if there is not enough information', () => {
const place = makeFakePlace({
id: '123',
- openingHours: {
+ regularOpeningHours: {
periods: [],
weekdayDescriptions: [],
},
@@ -249,7 +254,7 @@ describe('Opening hours utilities', () => {
it('returns a status if the place is never open', () => {
const place = makeFakePlace({
id: '123',
- openingHours: {
+ regularOpeningHours: {
periods: [],
weekdayDescriptions: [],
},
@@ -265,7 +270,7 @@ describe('Opening hours utilities', () => {
const tuesdayNoonSf = makeDateInLocale('2023-04-11T12:00', SF_OFFSET);
const place = makeFakePlace({
id: '123',
- openingHours: {
+ regularOpeningHours: {
periods: [makePeriod(TUE, 9, TUE, 17)], // Tuesday 9am - 5pm
weekdayDescriptions: [],
},
@@ -279,7 +284,7 @@ describe('Opening hours utilities', () => {
it('returns the next time the place will open', () => {
const thursday6PmSf = makeDateInLocale('2023-04-13T18:00', SF_OFFSET);
- const openingHours: OpeningHours = {
+ const regularOpeningHours: OpeningHours = {
periods: [
makePeriod(WED, 9, WED, 17), // Wed 9am - 5pm
makePeriod(THU, 9, THU, 17), // Thurs 9am - 5pm
@@ -287,12 +292,12 @@ describe('Opening hours utilities', () => {
],
weekdayDescriptions: []
};
- const place =
- makeFakePlace({id: '123', openingHours, utcOffsetMinutes: SF_OFFSET});
+ const place = makeFakePlace(
+ {id: '123', regularOpeningHours, utcOffsetMinutes: SF_OFFSET});
expect(getUpcomingOpenTime(place, thursday6PmSf)).toEqual({
status: NextOpenTimeStatus.WILL_OPEN,
- openPoint: openingHours.periods[2].open,
+ openPoint: regularOpeningHours.periods[2].open,
openDate: makeDateInLocale('2023-04-14T09:00', SF_OFFSET) // 9am Fri
});
});
@@ -304,7 +309,7 @@ describe('Opening hours utilities', () => {
//
// Sequence is (now) -> (week start) -> (period start)
const saturdayNoonSf = makeDateInLocale('2023-04-15T12:00', SF_OFFSET);
- const openingHours: OpeningHours = {
+ const regularOpeningHours: OpeningHours = {
periods: [
makePeriod(WED, 9, WED, 17), // Wed 9am - 5pm
makePeriod(THU, 9, THU, 17), // Thurs 9am - 5pm
@@ -312,12 +317,12 @@ describe('Opening hours utilities', () => {
],
weekdayDescriptions: []
};
- const place =
- makeFakePlace({id: '123', openingHours, utcOffsetMinutes: SF_OFFSET});
+ const place = makeFakePlace(
+ {id: '123', regularOpeningHours, utcOffsetMinutes: SF_OFFSET});
expect(getUpcomingOpenTime(place, saturdayNoonSf)).toEqual({
status: NextOpenTimeStatus.WILL_OPEN,
- openPoint: openingHours.periods[0].open,
+ openPoint: regularOpeningHours.periods[0].open,
openDate: makeDateInLocale('2023-04-19T09:00', SF_OFFSET) // 9am Wed
});
});
@@ -330,31 +335,34 @@ describe('Opening hours utilities', () => {
});
it('returns true if the place is always open', () => {
- const place = makeFakePlace(
- {id: '123', openingHours: ALWAYS_OPEN_HOURS, utcOffsetMinutes: 0});
+ const place = makeFakePlace({
+ id: '123',
+ regularOpeningHours: ALWAYS_OPEN_HOURS,
+ utcOffsetMinutes: 0,
+ });
expect(isOpen(place)).toBeTrue();
});
it('returns true if the place is open now', () => {
const mondayNoonSf = makeDateInLocale('2023-08-07T12:00', SF_OFFSET);
- const openingHours: OpeningHours = {
+ const regularOpeningHours: OpeningHours = {
periods: [makePeriod(MON, 9, MON, 17)], // Wed 9am - 5pm
weekdayDescriptions: []
};
- const place =
- makeFakePlace({id: '123', openingHours, utcOffsetMinutes: SF_OFFSET});
+ const place = makeFakePlace(
+ {id: '123', regularOpeningHours, utcOffsetMinutes: SF_OFFSET});
expect(isOpen(place, mondayNoonSf)).toBeTrue();
});
it('returns false if the place is not open now', () => {
const mondayEarlySf = makeDateInLocale('2023-08-07T06:00', SF_OFFSET);
- const openingHours: OpeningHours = {
+ const regularOpeningHours: OpeningHours = {
periods: [makePeriod(MON, 9, MON, 17)], // Wed 9am - 5pm
weekdayDescriptions: []
};
- const place =
- makeFakePlace({id: '123', openingHours, utcOffsetMinutes: SF_OFFSET});
+ const place = makeFakePlace(
+ {id: '123', regularOpeningHours, utcOffsetMinutes: SF_OFFSET});
expect(isOpen(place, mondayEarlySf)).toBeFalse();
});
diff --git a/src/utils/place_utils.ts b/src/utils/place_utils.ts
index bc51a22..63cd1db 100644
--- a/src/utils/place_utils.ts
+++ b/src/utils/place_utils.ts
@@ -171,7 +171,7 @@ export async function makePlaceFromPlaceResult(
*/
export function hasDataForOpeningCalculations(place: Place): boolean {
return !!(
- place.businessStatus && place.openingHours &&
+ place.businessStatus && place.regularOpeningHours &&
(place.utcOffsetMinutes != null));
}
@@ -228,7 +228,7 @@ function convertToPlaceFields(placeResult: PlaceResult): Partial {
// A place that is open 24/7 does not return a close period.
close: period.close ? makeOpeningHoursPoint(period.close) : null,
}));
- place.openingHours = {
+ place.regularOpeningHours = {
periods: periods ?? [],
weekdayDescriptions: placeResult.opening_hours.weekday_text ?? [],
};
@@ -320,7 +320,7 @@ const PLACE_TO_PLACE_RESULT_FIELDS:
'svgIconMaskURI': 'icon_mask_base_uri',
'internationalPhoneNumber': 'international_phone_number',
'displayName': 'name',
- 'openingHours': 'opening_hours',
+ 'regularOpeningHours': 'opening_hours',
'photos': 'photos',
'plusCode': 'plus_code',
'priceLevel': 'price_level',