Comments (2)
Sadly, this library doesn't do much outside of what is provided by the java.time API. This is the limitation of the DateTimeFormatter
:
boot.user=> (java.time.LocalDate/parse "2017/05" (java.time.format.DateTimeFormatter/ofPattern "yyyy/MM"))
java.time.DateTimeException: Unable to obtain LocalDate from TemporalAccessor: {Year=2017, MonthOfYear=5},ISO of type java.time.format.Parsed
java.time.format.DateTimeParseException: Text '2017/05' could not be parsed: Unable to obtain LocalDate from TemporalAccessor: {Year=2017, MonthOfYear=5},ISO of type java.time.format.Parsed
I can only recommend something like:
(defn month-year->local-date-time [^String str]
(->> (.split str "\\/") (map #(Integer/parseInt %)) (reverse) (apply j/local-date-time)))
from clojure.java-time.
I can imagine a feature that would harmonize the Number* -> TemporalEntity
constructors with their parse
counterparts. It should require a dynamic context set up before parsing, or a special kind of formatter used so that the default (strict) behaviour is preserved.
There's a DateTimeFormatter#parseUnresolved which can be used to obtain a parsed TemporalAccessor
which then needs to be resolved manually. However, there doesn't seem to be an easy way to just throw more default fields into the parse result and resolve it.
If anyone wants to tackle this - I'd be happy to collaborate :)
from clojure.java-time.
Related Issues (20)
- `zoned-date-time` with a single argument does not use `java-time.clock/make` HOT 1
- Canadian locale doesn't support AM/PM? HOT 1
- Instant < Interval breaks transitivity
- `not-{before,after}?` broken for equal arguments that need coercion
- t/> comparison and t/plus arithmetic support for java.sql.Timestamp HOT 1
- on-or-after? on-or-before? HOT 1
- Millisecond information for `java.sql.Time` is lost when converting to/from `LocalTime` HOT 1
- Unix timestamp conversion HOT 1
- Various properties gone missing in 0.3.3 HOT 7
- 0.3.3 - Year formatted wrongly on date roll ? HOT 3
- Consider Removing clj-tuple HOT 2
- Minor Clojure 1.11 Alpha 4 compatibility issue HOT 1
- Cut new release for Clojure 1.11 compat? HOT 23
- PriorityQueue class not found in babashka HOT 1
- Babashka Support HOT 1
- Type conversion graph is dependent on evaluation order HOT 1
- Deprecate single segment ns HOT 4
- Things like `java-time[.api]/truncate-to` do not work correctly when underlying protocol is extended HOT 5
- Case bug in https://github.com/dm3/clojure.java-time/blob/master/src/java_time/format.clj#L32 HOT 1
- `not-after?` not semantically equivalent to `<=` despite documentation implying otherwise HOT 5
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 clojure.java-time.