Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timezone support for strftime #37

Closed
rohitjoshi opened this issue Dec 18, 2014 · 4 comments
Closed

timezone support for strftime #37

rohitjoshi opened this issue Dec 18, 2014 · 4 comments
Labels
C-feature-request Category: a new feature (not already implemented)

Comments

@rohitjoshi
Copy link

When I use time::strftime("%Y-%m-%d %H:%M:%S %Z", &time::now()).unwrap(), I get timestamp without timezone. Here is output I get. 2014-12-18 12:32:31

How do I get timezone printed?

Here is equivalent python code

import datetime
import pytz
d = datetime.datetime.now(pytz.timezone("America/New_York"))
d.strftime("%Y-%m-%d %H:%M:%S %Z")

'2014-12-18 12:41:19 EST'

@afandian
Copy link

afandian commented Apr 23, 2016

It looks like named timezones are just ignored in parse.rs. The comment suggests that the C's original strptime is broken.

println!("{}", time::strptime("Tue Jan 01 12:37:48 GMT 2013", "%a %b %d %T %Z %Y").unwrap() == 
               time::strptime("Tue Jan 01 12:37:48 ETC 2013", "%a %b %d %T %Z %Y").unwrap());
=> true

However using time offsets does work

println!("{}", time::strptime("Tue Jan 01 12:37:48 +00:00 2013", "%a %b %d %T %z %Y").unwrap() == 
               time::strptime("Tue Jan 01 12:37:48 +05:00 2013", "%a %b %d %T %z %Y").unwrap());

My workaround's going to be string replacement (for now).

Perhaps there could be another parse function that does what's expected?

@jhpratt jhpratt added the v0.1 label Oct 1, 2019
@jhpratt
Copy link
Member

jhpratt commented Oct 4, 2019

My current thought is to drop the "support" for %Z in 0.2. That specific formatting option requires knowledge of the actual timezone, not just the offset, and this info isn't stored anywhere. Parsing may happen, though it isn't likely.

@jhpratt jhpratt added the C-feature-request Category: a new feature (not already implemented) label Oct 28, 2019
@jhpratt jhpratt added this to the tzdb support milestone Oct 28, 2019
@jhpratt jhpratt removed the v0.1 label Dec 3, 2019
@jhpratt
Copy link
Member

jhpratt commented Dec 4, 2019

The minimal support for %Z has been completely dropped for 0.2.

@jhpratt
Copy link
Member

jhpratt commented Dec 20, 2019

Closing in favor of #193, which would include this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: a new feature (not already implemented)
Projects
None yet
Development

No branches or pull requests

3 participants