API Documentation

Documentation for developing SailfishOS applications

DateTimeSettings Class

(Sailfish::Mdm::DateTimeSettings)

The DateTimeSettings class controls the system date and time. More...

Header: #include <mdm-datetime.h>

Properties

Public Functions

DateTimeSettings(QObject *parent = 0)
~DateTimeSettings()
bool automaticDateTimeUpdate() const
bool automaticTimeZoneUpdate() const
bool ready() const
void setAutomaticDateTimeUpdate(bool enable)
void setAutomaticTimeZoneUpdate(bool enable)
void setDate(const QDate &date)
void setTime(int hour, int minute)
void setTimeZone(const QString &timeZone)
QStringList supportedTimeZones()
QString timeZone() const

Signals

Detailed Description

The DateTimeSettings class controls the system date and time.

The date/time properties are not valid, and cannot be modified, until ready is true.

To use this class, clients must add the following to their qmake project:

 CONFIG += link_pkgconfig
 PKGCONFIG += sailfishmdm

and then #include <mdm-datetime.h>.

Example of usage:

 #include <mdm-datetime.h>
 void updateDateTimeSettings(QObject *parent)
 {
     Sailfish::Mdm::DateTimeSettings *dateTime = new Sailfish::Mdm::DateTimeSettings(parent);

     QObject::connect(dateTime, &Sailfish::Mdm::DateTimeSettings::readyChanged, [dateTime]() {

         // Disable automatic time zone updates so that the time zone can be changed with setTimeZone()
         dateTime->setAutomaticTimeZoneUpdate(false);

         // Disable automatic time zone updates so that the date and time can be changed with
         // setDate() and setTime()
         dateTime->setAutomaticDateTimeUpdate(false);

         dateTime->setDate(QDate(2000, 12, 25));
         dateTime->setTime(15, 35);
     });
 }

Property Documentation

automaticDateTimeUpdate : bool

This property holds true if the system date/time is automatically updated from a time server.

Access functions:

bool automaticDateTimeUpdate() const
void setAutomaticDateTimeUpdate(bool enable)

Notifier signal:

automaticTimeZoneUpdate : bool

This property holds true if the system time zone is automatically updated from a time server.

Access functions:

bool automaticTimeZoneUpdate() const
void setAutomaticTimeZoneUpdate(bool enable)

Notifier signal:

ready : const bool

This property holds true if the settings properties have been initialized and can be modified.

Access functions:

bool ready() const

Notifier signal:

void readyChanged()

timeZone : QString

This property holds the system time zone.

Access functions:

QString timeZone() const
void setTimeZone(const QString &timeZone)

Notifier signal:

See also supportedTimeZones().

Member Function Documentation

DateTimeSettings::DateTimeSettings(QObject *parent = 0)

Default constructs an instance of DateTimeSettings.

DateTimeSettings::~DateTimeSettings()

Destroys the instance of DateTimeSettings.

[signal] void DateTimeSettings::automaticDateTimeUpdateChanged()

This signal is emitted when the automaticDateTimeUpdate value changes.

Note: Notifier signal for property automaticDateTimeUpdate.

See also automaticDateTimeUpdate().

[signal] void DateTimeSettings::automaticTimeZoneUpdateChanged()

This signal is emitted when the automaticTimeZoneUpdate changes.

Note: Notifier signal for property automaticTimeZoneUpdate.

See also automaticTimeZoneUpdate().

[signal] void DateTimeSettings::dateTimeChanged()

This signal is emitted when the system date/time changes.

See also setDate() and setTime().

void DateTimeSettings::setDate(const QDate &date)

Sets the system date to the given date.

void DateTimeSettings::setTime(int hour, int minute)

Sets the system time to the hour and minute in 24-hour mode.

QStringList DateTimeSettings::supportedTimeZones()

Returns a list of valid time zones.

[signal] void DateTimeSettings::timeZoneChanged()

This signal is emitted when the timeZone changes.

Note: Notifier signal for property timeZone.

See also timeZone().

We use cookies to improve your user experience and to help us to develop our services. By continuing to browse the site, you approve of our use of cookies.