Skip to content

Added Time#middle_of_day method#10879

Merged
pixeltrix merged 1 commit intorails:masterfrom
makaroni4:master
Jul 29, 2013
Merged

Added Time#middle_of_day method#10879
pixeltrix merged 1 commit intorails:masterfrom
makaroni4:master

Conversation

@makaroni4
Copy link
Copy Markdown

No description provided.

@sikachu
Copy link
Copy Markdown
Member

sikachu commented Jun 7, 2013

I looked at #10878 and still doesn't see a rationale behind this. Would you mind telling us why this is useful to add?

@makaroni4
Copy link
Copy Markdown
Author

@sikachu sure

When one need to make a query relative to middle of the day (for example to show weather data, I faced this situation today) this method might be useful. Also there is Time#midnight method, but no Time#midday.

For sure initializer is a good place for keeping extensions like this, it is not a problem.

@senny
Copy link
Copy Markdown
Member

senny commented Jun 14, 2013

/cc @pixeltrix

@pixeltrix
Copy link
Copy Markdown
Contributor

@makaroni4 needs adding to DateTime as well

@pixeltrix
Copy link
Copy Markdown
Contributor

Thinking about it, adding morning? and afternoon? would be useful too.

@makaroni4
Copy link
Copy Markdown
Author

@pixeltrix thx, I will add midday to DateTime 👍

midday is the opposite of midnight, which difened for Time and DateTime so it is one of the reasons for me to add this method.

There is no opposite method for morning and afternoon (I think it should be smth like midnight) so I think it is a perfect scenario when initializer should be used.

@pixeltrix
Copy link
Copy Markdown
Contributor

There is past?, future? and today? though which is why I suggested adding morning? and afternoon?. Also missing are tomorrow? and yesterday?.

@killthekitten
Copy link
Copy Markdown
Contributor

Both hands are up for the tomorrow? and yesterday?

@PavelDemyanenko
Copy link
Copy Markdown

This might be usefull

@schneems
Copy link
Copy Markdown
Member

Interesting, could potentially find this useful. @makaroni4 are you going to add this to DateTime ?

@makaroni4
Copy link
Copy Markdown
Author

Hi, @schneems!

For sure, give me couple of minutes.

@makaroni4
Copy link
Copy Markdown
Author

@pixeltrix @schneems done.

I added methods for both Date and DateTime.

I see duplications of methods like beginning_of_day, end_of_day in Time and DateTime. Should we move them to DateAndDateTime module?

@makaroni4
Copy link
Copy Markdown
Author

@steveklabnik could you please take a look? This one should be either merged or closed 😃

@steveklabnik
Copy link
Copy Markdown
Member

I like to let @pixeltrix merge stuff related to time.

@guilleiguaran
Copy link
Copy Markdown
Member

@pixeltrix aka Kronos, god of the time 😁

@pixeltrix
Copy link
Copy Markdown
Contributor

@makaroni4 I hadn't merged it yet because the build failed and I thought you might be adding the other methods that had been suggested. No matter - can you check out why the tests are failing and update the PR. There is a significant amount of duplication between DateTime and Time calculations but we'll leave that for another PR.

@makaroni4
Copy link
Copy Markdown
Author

@pixeltrix I see that it was activerecord test failed: Failed components: activerecord:postgresql:isolated.

Could you please restart the build (I probably have no access, because button is locked on Travis)? I have no such an error on my local machine.

@makaroni4
Copy link
Copy Markdown
Author

@pixeltrix the build is green 😄 👍 You rebuilt it or how did it happen?

I will work on DRYing date and time modules in the next PR (as long as tomorrow? and yesterday? methods).

@pixeltrix
Copy link
Copy Markdown
Contributor

@makaroni4 can you squash the commits - once you've done that I'll merge 👍

Added middle_of_day method to Date and DateTime
@makaroni4
Copy link
Copy Markdown
Author

@pixeltrix the build is failed again due to bundler error in AR tests: https://travis-ci.org/rails/rails/jobs/9582396

@pixeltrix
Copy link
Copy Markdown
Contributor

@makaroni4 rebuilding that job now - we're nearly there 😄

@makaroni4
Copy link
Copy Markdown
Author

😄

pixeltrix added a commit that referenced this pull request Jul 29, 2013
Added Time#middle_of_day method
@pixeltrix pixeltrix merged commit c901056 into rails:master Jul 29, 2013
@pixeltrix
Copy link
Copy Markdown
Contributor

@makaroni4 thanks for you contribution and your patience ❤️

@makaroni4
Copy link
Copy Markdown
Author

Yay! @pixeltrix thank you very much 😃 ❤️

@kirs
Copy link
Copy Markdown
Member

kirs commented Sep 9, 2013

BTW, what about changelog?

rafaelfranca added a commit that referenced this pull request Sep 12, 2013
@rafaelfranca
Copy link
Copy Markdown
Member

Huge 👍 for CHANGELOG. Added

@makaroni4
Copy link
Copy Markdown
Author

@rafaelfranca sorry, I am late (back to school 😃 )

Thanks a lot for the CHANGELOG 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.