ClusterLabs / crmsh

Command-line interface for High-Availability cluster management on GNU/Linux systems.
GNU General Public License v2.0
131 stars 94 forks source link

About time convert #183

Closed liangxin1300 closed 1 year ago

liangxin1300 commented 7 years ago

crmsh.utils.parse_to_timestamp("2pm") --> 1487916000.0 crmsh.utils.timestamp_to_datetime(1487916000.0).strftime("%Y-%m-%d %H:%M") --> '2017-02-24 06:00'

But, when I use shell: echo "1487916000.0"|awk '{ print strftime("%Y-%m-%d %H:%M", $1); }' --> 2017-02-24 14:00

I think "2pm" convert to "2017-02-24 14:00" is right So, is there some problems in function "timestamp_to_datetime"?

krig commented 7 years ago

The question is, what timezone are you in? When I run crmsh.utils.parse_to_timestamp("2pm"), I get

In [9]: crmsh.utils.parse_to_timestamp("2pm")
Out[9]: 1487941200.0

parse_to_timestamp is not designed to parse ambiguous time definitions, and tries to convert dates that don't have an explicit timezone specifier from whatever the local timezone is into UTC.