default_delete<UserDevice>{}};
}
-shared_ptr<Packet> Context::create_header_packet(Glib::TimeVal start_time)
+shared_ptr<Packet> Context::create_header_packet(Glib::DateTime start_time)
{
auto header = g_new(struct sr_datafeed_header, 1);
header->feed_version = 1;
- header->starttime.tv_sec = start_time.tv_sec;
- header->starttime.tv_usec = start_time.tv_usec;
+ header->starttime.tv_sec = start_time.to_unix();
+ header->starttime.tv_usec = start_time.get_microsecond();
auto packet = g_new(struct sr_datafeed_packet, 1);
packet->type = SR_DF_HEADER;
packet->payload = header;
return _structure->feed_version;
}
-Glib::TimeVal Header::start_time() const
+Glib::DateTime Header::start_time() const
{
- return Glib::TimeVal(
- _structure->starttime.tv_sec,
- _structure->starttime.tv_usec);
+ Glib::DateTime time = Glib::DateTime::create_now_utc(_structure->starttime.tv_sec);
+ return time.add_seconds(_structure->starttime.tv_usec / 1.0e6);
}
Meta::Meta(const struct sr_datafeed_meta *structure) :
std::shared_ptr<UserDevice> create_user_device(
std::string vendor, std::string model, std::string version);
/** Create a header packet. */
- std::shared_ptr<Packet> create_header_packet(Glib::TimeVal start_time);
+ std::shared_ptr<Packet> create_header_packet(Glib::DateTime start_time);
/** Create a meta packet. */
std::shared_ptr<Packet> create_meta_packet(
std::map<const ConfigKey *, Glib::VariantBase> config);
/* Feed version number. */
int feed_version() const;
/* Start time of this session. */
- Glib::TimeVal start_time() const;
+ Glib::DateTime start_time() const;
private:
explicit Header(const struct sr_datafeed_header *structure);
~Header();