Comments (3)
Right ... %Y will happily continue to consume digits for the year, and there is no backtracking to retry failed matches with less greediness.
If you know that your year spans exactly four digits, use the %E4Y specifier. That is "%E4Y%m%d" will successfully parse "20140304" as 2014-03-04.
Aside: "%Y%m%d" on "20140304" doesn't return 1970-01-01 ... it fails (returns false) and leaves the output time_point alone.
from cctz.
Great to know, thank you!
I wonder whether this may possibly become a somewhat frequent issue when adopted as standard ("%Y" is quite common after all, as are time formats without delimiters), the format strings might better be kept backwards-compatible to strftime()/strptime(), and extensions should be pure extensions, without breaking traditional, expected behavior?
A possible backwards-compatible format could be:
"%Y" -- strptime()-like four-digit year YYYY
"%E#Y" -- Year with # digits of fractional precision
"%EY" -- Year with arbitrary fractional precision
What do you think?
from cctz.
Hi,
Thanks for the suggestion. We agree with you that this might be a not-totally-uncommon transition issue. However, we also think that the current greedy %Y is the "best" behavior.
So, for the time being we'll add something more prominent to time_zone.h where %Y is described. However we will certainly raise this question during any standardization process.
Thanks again.
from cctz.
Related Issues (20)
- Feature Request: Support parsing 'T' and 'Z' case insensitively
- Installation with lubridate package on AIX7.2 failed due to mutex error HOT 10
- MSVC compiler warnings (level 4) cosmetic
- Linker errors on FreeBSD (-lm missing) HOT 1
- Lone test `MakeTime.SysSecondsLimits` fails on FreeBSD/Clang HOT 9
- Build failure on arm64-uwp HOT 8
- cctz fails to build on AIX
- hash support for cctz::time_point<cctz::seconds> ? HOT 2
- %E produces different results in OS X vs Linux HOT 4
- Help with underflows on Fuchsia HOT 3
- Detect if include/cctz/time_zone.h:join_seconds() would overflow the output time_point HOT 2
- [Docs] Possible outdated documentation HOT 1
- Add fraction of seconds support HOT 3
- loadtimezone and n_sec impl is slow in starrocks HOT 4
- [Bug]: time_zone_format.cc causes compilation issues under QNX HOT 1
- Commit 6355d60 broke FreeBSD builds HOT 4
- Help!!! How to get specific current timezone name? HOT 7
- TimeZones.LoadZonesConcurrently test failure on Debian Sid/Trixie HOT 7
- Please, release a new version HOT 2
- Do you have correctness guarantee of time BCE? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cctz.