In this post, we will see how to resolve Compare DateTime against current system time?
Question:
I’m trying to make a C# method to fulfill this user story.These are the 2 acceptance criteria
- Start time must be at least one hour later than the current system time.
- End time must be at last one hour after start time.
Both of the start and end time must be DateTime values, so I can parse it with the TryParse method.
Here’s what I have in my code so far:
`
I’m not fully sure how the DateTime type works yet, but later on, I’d need to get an output string with this format: “The pickup window for your order will be 04:00 on 30/10/2022 and 20:00 on 30/10/2022”, and just replace the data in the string with values from datetimeStart and datetimeEnd
Best Answer:
DateTime
provides all the tools to write your conditions in straightforward code:one hour later than / after checkTime
is just
someTime must be at least one hour later than / after checkTime
becomes
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review