GooglePlacesSwift Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
OpeningHours
struct OpeningHours
extension OpeningHours : Copyable, CustomStringConvertible, Equatable, Escapable, Hashable, Sendable
A type to handle storing and accessing opening hours information for Place
.
-
Returns a Boolean value indicating whether two values are equal.
Equality is the inverse of inequality. For any values a
and b
,
a == b
implies that a != b
is false
.
Declaration
Swift
static func == (lhs: OpeningHours, rhs: OpeningHours) -> Bool
Parameters
lhs
|
|
rhs
|
Another value to compare.
|
-
A textual representation of this instance.
Calling this property directly is discouraged. Instead, convert an
instance of any type to a string by using the String(describing:)
initializer. This initializer works with any type, and uses the custom
description
property for types that conform to
CustomStringConvertible
:
struct Point: CustomStringConvertible {
let x: Int, y: Int
var description: String {
return "(\(x), \(y))"
}
}
let p = Point(x: 21, y: 30)
let s = String(describing: p)
print(s)
// Prints "(21, 30)"
The conversion of p
to a string in the assignment to s
uses the
Point
type’s description
property.
Declaration
Swift
var description: String { get }
-
Hashes the essential components of this value by feeding them into the
given hasher.
Implement this method to conform to the Hashable
protocol. The
components used for hashing must be the same as the components compared
in your type’s ==
operator implementation. Call hasher.combine(_:)
with each of these components.
Important
In your implementation of hash(into:)
,
don’t call finalize()
on the hasher
instance provided,
or replace it with a different instance.
Doing so may become a compile-time error in the future.
Declaration
Swift
func hash(into hasher: inout Hasher)
-
The hash value.
Hash values are not guaranteed to be equal across different executions of
your program. Do not save hash values to use during a future execution.
Important
hashValue
is deprecated as a
Hashable
requirement. To
conform to
Hashable
, implement the
hash(into:)
requirement instead.
The compiler provides an implementation for
hashValue
for you.
Declaration
Swift
var hashValue: Int { get }
-
-
Instantiates an OpeningHours
with the specified information.
OpeningHours
s can be gotten from a Place
object. This initializer can be used for
testing.
Example:
let openingHoursDict = [
"open_now": true,
"periods": [
[
"close": ["day": 1, "time": "1730"],
"open": ["day": 1, "time": "0830"],
],
[
"close": ["day": 4, "time": "1930"],
"open": ["day": 4, "time": "0730"],
],
]
Declaration
Swift
init(jsonDictionary: [String : Any])
-
Contains all Period
s of open and close events for the week.
Note
Multiple periods can be associated with a day (eg. Monday 7am - Monday 2pm, Monday
5pm - Monday 10pm). Periods may also span multiple days (eg Friday 7pm - Saturday 2am).
Declaration
Swift
var periods: [Period] { get }
-
Returns a list of SpecialDay
entries, corresponding to the next
seven days which may have opening hours that differ from the normal operating hours.
-
Contains localized strings of the daily opening hours for the week.
Note
The order of the text depends on the language and may begin on Monday or Sunday. Do
not use the
DayOfWeek
` enum to index into the array.
Declaration
Swift
var weekdayText: [String] { get }
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-27 UTC.
[null,null,["Last updated 2025-08-27 UTC."],[[["\u003cp\u003e\u003ccode\u003eOpeningHours\u003c/code\u003e stores and manages opening hours information for Google Places.\u003c/p\u003e\n"],["\u003cp\u003eIt provides properties like \u003ccode\u003eperiods\u003c/code\u003e, \u003ccode\u003eweekdayText\u003c/code\u003e, and \u003ccode\u003especialDays\u003c/code\u003e for detailed hour data.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOpeningHours\u003c/code\u003e conforms to \u003ccode\u003eCustomStringConvertible\u003c/code\u003e, \u003ccode\u003eEquatable\u003c/code\u003e, and \u003ccode\u003eHashable\u003c/code\u003e protocols.\u003c/p\u003e\n"],["\u003cp\u003eYou can create an \u003ccode\u003eOpeningHours\u003c/code\u003e instance using a JSON dictionary or access it from a \u003ccode\u003ePlace\u003c/code\u003e object.\u003c/p\u003e\n"]]],["The `OpeningHours` type manages a place's operational hours, supporting string conversion, equality checks, and hashing. It stores data like `hoursType`, `periods` (open/close times), `specialDays` (deviating hours), and `weekdayText` (daily hour strings). The data can be provided using `jsonDictionary` for testing. It can be compared using the `==` operator and uses `hash(into:)` and `hashValue` to be hashable.\n"],null,["# GooglePlacesSwift Framework Reference\n\nOpeningHours\n============\n\n struct OpeningHours\n\n extension OpeningHours : Copyable, CustomStringConvertible, Equatable, Escapable, Hashable, Sendable\n\nA type to handle storing and accessing opening hours information for [Place](../Structs/Place.html).\n- `\n ``\n ``\n `\n\n ### [==(_:_:)](#/s:17GooglePlacesSwift12OpeningHoursV2eeoiySbAC_ACtFZ)\n\n `\n ` \n Returns a Boolean value indicating whether two values are equal.\n\n Equality is the inverse of inequality. For any values `a` and `b`,\n `a == b` implies that `a != b` is `false`. \n\n #### Declaration\n\n Swift \n\n static func == (lhs: OpeningHours, rhs: OpeningHours) -\u003e Bool\n\n #### Parameters\n\n |-------------|---------------------------|\n | ` `*lhs*` ` | A value to compare. |\n | ` `*rhs*` ` | Another value to compare. |\n\n- `\n ``\n ``\n `\n\n ### [description](#/s:17GooglePlacesSwift12OpeningHoursV11descriptionSSvp)\n\n `\n ` \n A textual representation of this instance.\n\n Calling this property directly is discouraged. Instead, convert an\n instance of any type to a string by using the `String(describing:)`\n initializer. This initializer works with any type, and uses the custom\n `description` property for types that conform to\n `CustomStringConvertible`: \n\n struct Point: CustomStringConvertible {\n let x: Int, y: Int\n\n var description: String {\n return \"(\\(x), \\(y))\"\n }\n }\n\n let p = Point(x: 21, y: 30)\n let s = String(describing: p)\n print(s)\n // Prints \"(21, 30)\"\n\n The conversion of `p` to a string in the assignment to `s` uses the\n `Point` type's `description` property. \n\n #### Declaration\n\n Swift \n\n var description: String { get }\n\n- `\n ``\n ``\n `\n\n ### [hash(into:)](#/s:17GooglePlacesSwift12OpeningHoursV4hash4intoys6HasherVz_tF)\n\n `\n ` \n Hashes the essential components of this value by feeding them into the\n given hasher.\n\n Implement this method to conform to the `Hashable` protocol. The\n components used for hashing must be the same as the components compared\n in your type's `==` operator implementation. Call `hasher.combine(_:)`\n with each of these components. \n Important\n\n In your implementation of `hash(into:)`,\n don't call `finalize()` on the `hasher` instance provided,\n or replace it with a different instance.\n Doing so may become a compile-time error in the future. \n\n #### Declaration\n\n Swift \n\n func hash(into hasher: inout Hasher)\n\n- `\n ``\n ``\n `\n\n ### [hashValue](#/s:17GooglePlacesSwift12OpeningHoursV9hashValueSivp)\n\n `\n ` \n The hash value.\n\n Hash values are not guaranteed to be equal across different executions of\n your program. Do not save hash values to use during a future execution. \n Important\n `hashValue` is deprecated as a `Hashable` requirement. To conform to `Hashable`, implement the [hash(into:)](../Structs/OpeningHours.html#/s:17GooglePlacesSwift12OpeningHoursV4hash4intoys6HasherVz_tF) requirement instead. The compiler provides an implementation for `hashValue` for you. \n\n #### Declaration\n\n Swift \n\n var hashValue: Int { get }\n\n- `\n ``\n ``\n `\n\n ### [hoursType](#/s:17GooglePlacesSwift12OpeningHoursV9hoursTypeAA0eG0OSgvp)\n\n `\n ` \n Returns the [HoursType](../Enums/HoursType.html) of the opening hours. \n\n #### Declaration\n\n Swift \n\n var hoursType: ../Enums/HoursType.html? { get }\n\n- `\n ``\n ``\n `\n\n ### [init(jsonDictionary:)](#/s:17GooglePlacesSwift12OpeningHoursV14jsonDictionaryACSDySSypG_tcfc)\n\n `\n ` \n Instantiates an `OpeningHours` with the specified information.\n\n `OpeningHours`s can be gotten from a [Place](../Structs/Place.html) object. This initializer can be used for\n testing.\n\n Example: \n\n let openingHoursDict = [\n \"open_now\": true,\n \"periods\": [\n [\n \"close\": [\"day\": 1, \"time\": \"1730\"],\n \"open\": [\"day\": 1, \"time\": \"0830\"],\n ],\n [\n \"close\": [\"day\": 4, \"time\": \"1930\"],\n \"open\": [\"day\": 4, \"time\": \"0730\"],\n ],\n ]\n\n #### Declaration\n\n Swift \n\n init(jsonDictionary: [String : Any])\n\n- `\n ``\n ``\n `\n\n ### [periods](#/s:17GooglePlacesSwift12OpeningHoursV7periodsSayAA6PeriodVGvp)\n\n `\n ` \n Contains all [Period](../Structs/Period.html)s of open and close events for the week. \n Note\n Multiple periods can be associated with a day (eg. Monday 7am - Monday 2pm, Monday 5pm - Monday 10pm). Periods may also span multiple days (eg Friday 7pm - Saturday 2am). \n\n #### Declaration\n\n Swift \n\n var periods: [../Structs/Period.html] { get }\n\n- `\n ``\n ``\n `\n\n ### [specialDays](#/s:17GooglePlacesSwift12OpeningHoursV11specialDaysSayAA10SpecialDayVGvp)\n\n `\n ` \n Returns a list of [SpecialDay](../Structs/SpecialDay.html) entries, corresponding to the next\n seven days which may have opening hours that differ from the normal operating hours. \n\n #### Declaration\n\n Swift \n\n var specialDays: [../Structs/SpecialDay.html] { get }\n\n- `\n ``\n ``\n `\n\n ### [weekdayText](#/s:17GooglePlacesSwift12OpeningHoursV11weekdayTextSaySSGvp)\n\n `\n ` \n Contains localized strings of the daily opening hours for the week. \n Note\n The order of the text depends on the language and may begin on Monday or Sunday. Do not use the [DayOfWeek](../Enums/DayOfWeek.html)\\` enum to index into the array. \n\n #### Declaration\n\n Swift \n\n var weekdayText: [String] { get }"]]