Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZonedDateTime and OffsetDateTime could do with Date and Time properties #186

Closed
GoogleCodeExporter opened this issue Mar 15, 2015 · 4 comments
Milestone

Comments

@GoogleCodeExporter
Copy link

> What situation does this request make simpler?

Avoiding long property chains for little purpose.

To find out today's date in a particular zone, I currently have to use:

    var date = clock.Now.InZone(zone).LocalDateTime.Date;

Ditto for time of day.

Three options suggest themselves:

1) var date = clock.Now.InZone(zone).Date;
2) var date = clock.Now.InZone(zone).LocalDate;
3) var date = clock.Now.InZone(zone).Local.Date;

In the first two options it would be adding new properties to ZonedDateTime - 
either Date and Time, or LocalDate and LocalTime. In the third option it would 
be adding "Local" as a synonym for "LocalDateTime", which works nicely here but 
is a little bleh. Whatever we do for ZonedDateTime we should do for 
OffsetDateTime too.

I *think* I prefer option 1, but equally emphasizing the "local" part is nice 
too...

Original issue reported on code.google.com by jonsk...@google.com on 30 Jan 2013 at 11:25

@GoogleCodeExporter
Copy link
Author

Option 1 seems like the most sensible to me: we already provide Year, Month, 
Day, Hour, etc properties on both, which are clearly 'local' values, and so 
also adding in the Date and TimeOfDay [presumably? q.v. LocalDateTime] 
properties would make sense too; the return type and summary should make it 
clear that they're local dates/times.

Original comment by malcolm.rowe on 30 Jan 2013 at 11:37

@GoogleCodeExporter
Copy link
Author

Yes, let's go with that then - and definitely TimeOfDay to match LocalDateTime. 
I'd misremembered the name, but I definitely want them to match!

Will do it on the train tomorrow.

Original comment by jonsk...@google.com on 30 Jan 2013 at 11:39

@GoogleCodeExporter
Copy link
Author

Original comment by malcolm.rowe on 30 Jan 2013 at 11:40

  • Changed state: Accepted
  • Added labels: Type-Enhancement, Priority-Medium, Milestone-1.1.0

@GoogleCodeExporter
Copy link
Author

This issue was closed by revision b3629b3d7d3e.

Original comment by jonathan.skeet on 31 Jan 2013 at 7:12

  • Changed state: Fixed

@malcolmr malcolmr modified the milestone: 1.1.0 Mar 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants