KOpeningHours::OpeningHours
#include <openinghours.h>
Public Types | |
enum | Error { Null , NoError , SyntaxError , MissingRegion , MissingLocation , IncompatibleMode , UnsupportedFeature , EvaluationError } |
enum | Mode { IntervalMode = 1 , PointInTimeMode = 2 } |
typedef QFlags< Mode > | Modes |
Properties | |
Error | error |
float | latitude |
float | longitude |
QString | normalizedExpression |
QString | region |
QString | timeZone |
Public Member Functions | |
OpeningHours () | |
OpeningHours (const char *openingHours, std::size_t size, Modes modes=IntervalMode) | |
OpeningHours (const OpeningHours &) | |
OpeningHours (const QByteArray &openingHours, Modes modes=IntervalMode) | |
OpeningHours (OpeningHours &&) | |
Error | error () const |
Q_INVOKABLE KOpeningHours::Interval | interval (const QDateTime &dt) const |
float | latitude () const |
float | longitude () const |
Q_INVOKABLE KOpeningHours::Interval | nextInterval (const KOpeningHours::Interval &interval) const |
QByteArray | normalizedExpression () const |
OpeningHours & | operator= (const OpeningHours &) |
OpeningHours & | operator= (OpeningHours &&) |
QString | region () const |
void | setExpression (const char *openingHours, std::size_t size, Modes modes=IntervalMode) |
void | setExpression (const QByteArray &openingHours, Modes modes=IntervalMode) |
void | setLatitude (float latitude) |
Q_INVOKABLE void | setLocation (float latitude, float longitude) |
void | setLongitude (float longitude) |
void | setRegion (QStringView region) |
void | setTimeZone (const QTimeZone &tz) |
QByteArray | simplifiedExpression () const |
QTimeZone | timeZone () const |
Static Public Member Functions | |
static OpeningHours | fromJsonLd (const QJsonObject &obj) |
Detailed Description
An OSM opening hours specification.
This is the main entry point into this library, providing both a way to parse opening hours expressions and to evaluate them.
Definition at line 32 of file openinghours.h.
Member Typedef Documentation
◆ Modes
Definition at line 49 of file openinghours.h.
Member Enumeration Documentation
◆ Error
Error codes.
Definition at line 130 of file openinghours.h.
◆ Mode
Evaluation modes for opening hours expressions.
Enumerator | |
---|---|
IntervalMode | Expressions that describe time ranges. |
PointInTimeMode | Expressions that describe points in time. |
Definition at line 45 of file openinghours.h.
Property Documentation
◆ error
|
read |
Definition at line 35 of file openinghours.h.
◆ latitude
|
readwrite |
Definition at line 37 of file openinghours.h.
◆ longitude
|
readwrite |
Definition at line 38 of file openinghours.h.
◆ normalizedExpression
|
read |
Definition at line 36 of file openinghours.h.
◆ region
|
readwrite |
Definition at line 40 of file openinghours.h.
◆ timeZone
|
readwrite |
Definition at line 42 of file openinghours.h.
Constructor & Destructor Documentation
◆ OpeningHours() [1/3]
|
explicit |
Create an empty/invalid instance.
Definition at line 314 of file openinghours.cpp.
◆ OpeningHours() [2/3]
|
explicit |
Parse OSM opening hours expression openingHours
.
- Parameters
-
modes Specify whether time interval and/or point in time expressions are expected. If openingHours
doesn't matchmodes
, error() return IncompatibleMode.
Definition at line 320 of file openinghours.cpp.
◆ OpeningHours() [3/3]
|
explicit |
Parse OSM opening hours expression openingHours
.
- Parameters
-
modes Specify whether time interval and/or point in time expressions are expected. If openingHours
doesn't matchmodes
, error() return IncompatibleMode.
Definition at line 326 of file openinghours.cpp.
Member Function Documentation
◆ error()
OpeningHours::Error OpeningHours::error | ( | ) | const |
Error status of this expression.
Definition at line 506 of file openinghours.cpp.
◆ fromJsonLd()
|
static |
Convert opening hours in schema.org JSON-LD format.
This supports the following formats:
- https://schema.org/openingHours
- https://schema.org/openingHoursSpecification
- https://schema.org/specialOpeningHoursSpecification
Definition at line 663 of file openinghours.cpp.
◆ interval()
Returns the interval containing dt
.
Definition at line 512 of file openinghours.cpp.
◆ latitude()
float OpeningHours::latitude | ( | ) | const |
Definition at line 451 of file openinghours.cpp.
◆ longitude()
float OpeningHours::longitude | ( | ) | const |
Definition at line 462 of file openinghours.cpp.
◆ nextInterval()
Interval OpeningHours::nextInterval | ( | const KOpeningHours::Interval & | interval | ) | const |
Returns the interval immediately following interval
.
Definition at line 600 of file openinghours.cpp.
◆ normalizedExpression()
QByteArray OpeningHours::normalizedExpression | ( | ) | const |
Returns the OSM opening hours expression reconstructed from this object.
In many cases it will be the same as the expression given to the constructor or to setExpression, but some normalization can happen as well, especially in case of non-conform input.
Definition at line 403 of file openinghours.cpp.
◆ region()
QString OpeningHours::region | ( | ) | const |
Definition at line 474 of file openinghours.cpp.
◆ setExpression() [1/2]
void OpeningHours::setExpression | ( | const char * | openingHours, |
std::size_t | size, | ||
Modes | modes = IntervalMode ) |
Parse OSM opening hours expression openingHours
.
- Parameters
-
modes Specify whether time interval and/or point in time expressions are expected. If openingHours
doesn't matchmodes
, error() return IncompatibleMode. Prefer this over creating new instances if you are processing many expressions at once.
Definition at line 345 of file openinghours.cpp.
◆ setExpression() [2/2]
void OpeningHours::setExpression | ( | const QByteArray & | openingHours, |
OpeningHours::Modes | modes = IntervalMode ) |
Parse OSM opening hours expression openingHours
.
- Parameters
-
modes Specify whether time interval and/or point in time expressions are expected. If openingHours
doesn't matchmodes
, error() return IncompatibleMode. Prefer this over creating new instances if you are processing many expressions at once.
Definition at line 340 of file openinghours.cpp.
◆ setLatitude()
void OpeningHours::setLatitude | ( | float | latitude | ) |
Definition at line 456 of file openinghours.cpp.
◆ setLocation()
void OpeningHours::setLocation | ( | float | latitude, |
float | longitude ) |
Geographic coordinate at which this expression should be evaluated.
This is needed for expressions containing location-based variable time references, such as "sunset". If the expression requires a location, error() returns MissingLocation
if no location has been specified.
Definition at line 444 of file openinghours.cpp.
◆ setLongitude()
void OpeningHours::setLongitude | ( | float | longitude | ) |
Definition at line 467 of file openinghours.cpp.
◆ setRegion()
void OpeningHours::setRegion | ( | QStringView | region | ) |
ISO 3166-2 region or ISO 316-1 country in which this expression should be evaluated.
This is needed for expressions containing public holiday references ("PH"). If the expression references a public holiday, error() returns MissingRegion
if no region has been specified, or if no holiday data is available for the specified region.
Definition at line 479 of file openinghours.cpp.
◆ setTimeZone()
void OpeningHours::setTimeZone | ( | const QTimeZone & | tz | ) |
Timezone in which this expression should be evaluated.
If not specified, this assumes local time.
Definition at line 491 of file openinghours.cpp.
◆ simplifiedExpression()
QByteArray OpeningHours::simplifiedExpression | ( | ) | const |
Returns a simplified OSM opening hours expression reconstructed from this object.
In many cases it will be the same as normalizedExpression(), but further simplifications can happen, to make the expression shorter/simpler.
Definition at line 432 of file openinghours.cpp.
◆ timeZone()
QTimeZone OpeningHours::timeZone | ( | ) | const |
Definition at line 486 of file openinghours.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 12:01:04 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.