Comments (7)
It's possible, dateparser
could detect the format of a date string, internally.
But, the format detected is regex
, is it what you want?
from dateparser.
Not really, need a standard according to https://www.w3.org/TR/NOTE-datetime. So that format can be reused with other libraries, possibly in other languages. For example, when the back end processes a csv document, it sends the converted data with format information that the front end processes with their libraries.
from dateparser.
Example to use:
var date = "1994-11-05 13:15:30";
var dateFormat = DateParserUtils.parseFormat(date);
assert dateFormat = "YYYY-MM-DD hh:mm:ss";
var date = "1994-11-05";
var dateFormat = DateParserUtils.parseFormat(date);
assert dateFormat = "YYYY-MM-DD";
var date = "11-05-1994 13:15:30";
var dateFormat = DateParserUtils.parseFormat(date);
assert dateFormat = "DD-MM-YYYY hh:mm:ss";
var date = "11-05";
var dateFormat = DateParserUtils.parseFormat(date);
assert dateFormat = "DD-MM";
var date = "04 Jul 2021 19:59:09";
var dateFormat = DateParserUtils.parseFormat(date);
assert dateFormat = "DD MMM YYYY hh:mm:ss";
from dateparser.
There has too many formats supported in dateparser
, I don't think it's a good idea to use it like this.
from dateparser.
Hi @sisyphsu ,
lets say we have csv file .... we want to format a date column .... we can improve performance if we know date format
so can we get date format
thanks
from dateparser.
I was about to start implementing the code to get the date format given the date string.
Then I stopped because there are some test cases which are making trouble.
- 11/11/2022
Is it in DD/MM/YYYY format or MM/DD/YYYY?
Its better to have or follow the date/time format in a project where we are defining these.
from dateparser.
You can declare precedence for formats.
When somebody passes one string to the method, you check a list of formats by precedence.
If need to find a format for the string list need create another method for this case. Although, format check logic can be reused.
from dateparser.
Related Issues (20)
- Throw error when argument is empty String
- Wrong selection of a matching rule HOT 1
- Custom Rule Failure HOT 1
- Thank you so much for writing this library! HOT 1
- Not available in maven repository HOT 1
- (How to?) Improve performance when parsing many strings in the same format
- ISO formatted string is parsed wrong HOT 4
- Parsing a date with some negative offsets raises an exception. HOT 1
- Support modern JDK versions by updating lombok to 1.18.10 (or newer) HOT 2
- preferMonthFirst is not reset when month is given greater than 12 HOT 3
- Date Parsing Rpoblem HOT 2
- Unneeded patterns/rules influence the result of the parsing
- Lombok dependency leaking into projects that use Dateparser HOT 2
- There is a problem with too large timestamp HOT 1
- Format exception HOT 1
- Weird bug - Custom date parser for parsing dates with zero prefixes
- The parser doesn't allow setting the default timezone (if timezone is not present in the string)
- Returning a hint whether the parsing was deterministic or not
- Support small timestamp. HOT 1
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 dateparser.