This commit is contained in:
parent
3a85891f2e
commit
b11e18e560
@ -7,6 +7,7 @@
|
|||||||
<property name="NTP" type="b" access="read"/>
|
<property name="NTP" type="b" access="read"/>
|
||||||
<property name="CanNTP" type="b" access="read"/>
|
<property name="CanNTP" type="b" access="read"/>
|
||||||
<property name="NTPSynchronized" type="b" access="read"/>
|
<property name="NTPSynchronized" type="b" access="read"/>
|
||||||
|
<property name="TimeUSecRTC" type="t" access="read"/>
|
||||||
<method name="SetTime">
|
<method name="SetTime">
|
||||||
<arg name="usec_utc" type="x" direction="in"/>
|
<arg name="usec_utc" type="x" direction="in"/>
|
||||||
<arg name="relative" type="b" direction="in"/>
|
<arg name="relative" type="b" direction="in"/>
|
||||||
|
@ -125,12 +125,16 @@ static void slack_get_property(Glib::VariantBase& result, const Glib::RefPtr<Gio
|
|||||||
{
|
{
|
||||||
result = Glib::Variant<bool>::create(dlackware::timedate::ntp_synchronized());
|
result = Glib::Variant<bool>::create(dlackware::timedate::ntp_synchronized());
|
||||||
}
|
}
|
||||||
|
else if (prop_name == "TimeUSecRTC")
|
||||||
|
{
|
||||||
|
result = Glib::Variant<std::uint64_t>::create(dlackware::timedate::time_usec_rtc());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace dlackware::timedate
|
namespace dlackware::timedate
|
||||||
{
|
{
|
||||||
constexpr const std::int32_t usec_per_sec = 1000000ULL;
|
constexpr const std::uint64_t usec_per_sec = 1000000ULL;
|
||||||
constexpr const std::int32_t nsec_per_usec = 1000ULL;
|
constexpr const std::uint64_t nsec_per_usec = 1000ULL;
|
||||||
|
|
||||||
timedate1::timedate1()
|
timedate1::timedate1()
|
||||||
: interface_vtable{ &slack_method_call, &slack_get_property }
|
: interface_vtable{ &slack_method_call, &slack_get_property }
|
||||||
@ -247,7 +251,7 @@ namespace dlackware::timedate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_time(gint64 seconds_since_epoch, bool relative, bool)
|
void set_time(std::int64_t seconds_since_epoch, bool relative, bool)
|
||||||
{
|
{
|
||||||
timespec ts;
|
timespec ts;
|
||||||
|
|
||||||
@ -333,4 +337,10 @@ namespace dlackware::timedate
|
|||||||
}
|
}
|
||||||
return ntp_result != TIME_ERROR && (buffer.status & STA_UNSYNC) == 0;
|
return ntp_result != TIME_ERROR && (buffer.status & STA_UNSYNC) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::uint64_t time_usec_rtc()
|
||||||
|
{
|
||||||
|
return std::chrono::duration_cast<std::chrono::microseconds>(
|
||||||
|
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,9 @@ namespace dlackware::timedate
|
|||||||
// Shows whether the kernel reports the time as synchronized.
|
// Shows whether the kernel reports the time as synchronized.
|
||||||
bool ntp_synchronized();
|
bool ntp_synchronized();
|
||||||
|
|
||||||
|
// Shows the current time in the RTC.
|
||||||
|
std::uint64_t time_usec_rtc();
|
||||||
|
|
||||||
// Returns the timezones available on the system.
|
// Returns the timezones available on the system.
|
||||||
std::vector<Glib::ustring> list_timezones();
|
std::vector<Glib::ustring> list_timezones();
|
||||||
|
|
||||||
@ -57,7 +60,7 @@ namespace dlackware::timedate
|
|||||||
// Changes the date/time
|
// Changes the date/time
|
||||||
// Takes the amount of seconds since UNIX epoche and
|
// Takes the amount of seconds since UNIX epoche and
|
||||||
// Throws std::system_error.
|
// Throws std::system_error.
|
||||||
void set_time(gint64 seconds_since_epoch, bool relative, bool user_interaction);
|
void set_time(std::int64_t seconds_since_epoch, bool relative, bool user_interaction);
|
||||||
|
|
||||||
class timedate1
|
class timedate1
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user