Ask Your Question
0

Convience methods to convert rospy.Time to datetime.datetime

asked 2018-03-26 14:38:02 -0600

ivaughn gravatar image

I couldn't find any convenience methods to convert rospy.Time to datetime.datetime. Timezones and other issues make this less trivial than it appears, especially for novice users.

Am I missing something obvious, or is this a textbook case of "nope, not done yet, please submit a patch?"

Thanks!

edit retag flag offensive close merge delete

Comments

I would say this is indeed something that just hasn't been done yet. Shouldn't be too difficult though: rospy.Time is a Unix stamp, so conversions should be against UTC, correct?

gvdhoorn gravatar image gvdhoorn  ( 2018-03-27 02:39:06 -0600 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2020-11-10 23:47:16 -0600

rgov gravatar image

rospy.Time to datetime.datetime:

datetime.utcfromtimestamp(T.to_sec())

datetime.datetime to rospy.Time:

rospy.Time.from_sec(T.replace(tzinfo=datetime.timezone.utc).timestamp())
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-03-26 14:38:02 -0600

Seen: 1,402 times

Last updated: Nov 10 '20