Comments (2)
Would this work you? https://github.com/waltzofpearls/belt/blob/main/dateparser/examples/parse_with.rs
use chrono::{
naive::NaiveTime,
offset::{Local, Utc},
};
use dateparser::parse_with;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let parsed_in_local = parse_with("2021-10-09", &Local, NaiveTime::from_hms(0, 0, 0))?;
println!("{:#?}", parsed_in_local);
let parsed_in_utc = parse_with("2021-10-09", &Utc, NaiveTime::from_hms(0, 0, 0))?;
println!("{:#?}", parsed_in_utc);
Ok(())
}
It printed the following at the time I ran it.
2021-10-10T00:00:00Z
2021-10-09T00:00:00Z
Both zero out time. The difference is the first one assumes it's a local date, and the second parses the date with UTC.
from dateparser.
@waltzofpearls unfortunately this would not resolve my issue, the core of the issue is setting unknown parts of a DateTime with the current Local or UTC time rather than zeroing them out.
Thanks for your time, I think I'm going to invest some time in a more custom solution for now.
from dateparser.
Related Issues (12)
- `parse` returns datetime with time set to current local time... HOT 2
- Default time for incomplete datetime strings HOT 3
- missing support for a plausable format HOT 4
- Feature Request: replace `chrono` HOT 2
- Convert `anyhow::Result`s in parsing functions to custom error type. HOT 1
- Three date formats HOT 1
- Default date is not configurable HOT 6
- awk mktime date format support
- Add weekday name support for date: Wednesday, 19 May 2027
- Natural language support HOT 2
- Seemingly arbitrary leniency towards commas
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.