[ndnSIM] Converting from nanoseconds to seconds

Alex Afanasyev alexander.afanasyev at ucla.edu
Tue Mar 24 08:27:10 PDT 2015


Hi!

Given nanoseconds-to-seconds conversion includes information truncation, you would need to explicitly specify this intention using duration_cast method (you can check more about duration_cast in Boost.Chrono documentation http://www.boost.org/doc/libs/1_57_0/doc/html/chrono/users_guide.html <http://www.boost.org/doc/libs/1_57_0/doc/html/chrono/users_guide.html> or in std::chrono docs http://en.cppreference.com/w/cpp/chrono/duration/duration_cast <http://en.cppreference.com/w/cpp/chrono/duration/duration_cast>):

There is also a small problem with your example. time::steady_clock::now() returns a so called “time point” (time duration since some fixed epoch).  More correct example would look similar to:

  ::ndn::time::steady_clock::TimePoint now = ::ndn::time::steady_clock::now();
  ::ndn::time::seconds sec = ::ndn::time::duration_cast<::ndn::time::seconds>(now.time_since_epoch());

—
Alex


> On Mar 24, 2015, at 6:48 AM, 최원준 <wonjunchoi001 at gmail.com> wrote:
> 
> Hello.
> 
> How can I convert from nanoseconds to seconds?
> time::nanoseconds time= time::steady_clock::now()
> time.getseconds() is not working.
> 
> Best regards.
> Wonjun, Choi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20150324/31b6b551/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20150324/31b6b551/attachment.bin>


More information about the ndnSIM mailing list