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 QByteArray &openingHours, Modes modes=IntervalMode) | |
OpeningHours (const char *openingHours, std::size_t size, Modes modes=IntervalMode) | |
OpeningHours (const OpeningHours &) | |
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 QByteArray &openingHours, Modes modes=IntervalMode) |
void | setExpression (const char *openingHours, std::size_t size, 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) |
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 Enumeration Documentation
Error codes.
Definition at line 124 of file openinghours.h.
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.
Constructor & Destructor Documentation
|
explicit |
Create an empty/invalid instance.
Definition at line 171 of file openinghours.cpp.
|
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 177 of file openinghours.cpp.
|
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 183 of file openinghours.cpp.
Member Function Documentation
Error KOpeningHours::OpeningHours::error | ( | ) | const |
Error status of this expression.
|
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 510 of file openinghours.cpp.
Returns the interval containing dt
.
Definition at line 359 of file openinghours.cpp.
Interval OpeningHours::nextInterval | ( | const KOpeningHours::Interval & | interval | ) | const |
Returns the interval immediately following interval
.
Definition at line 447 of file openinghours.cpp.
QByteArray KOpeningHours::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.
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 197 of file openinghours.cpp.
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 202 of file openinghours.cpp.
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 291 of file openinghours.cpp.
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 326 of file openinghours.cpp.
void OpeningHours::setTimeZone | ( | const QTimeZone & | tz | ) |
Timezone in which this expression should be evaluated.
If not specified, this assumes local time.
Definition at line 338 of file openinghours.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 19 2021 23:07:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.