aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_ext_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #10634 from teleological/time_advance_gregorianAndrew White2014-01-051-0/+7
|\ | | | | Maintain proleptic gregorian in Time#advance
| * Maintain proleptic gregorian in Time#advanceRiley Lynch2013-05-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Time#advance uses Time#to_date and Date#advance to calculate a new date. The Date object returned by Time#to_date is constructed with the assumption that the Time object represents a proleptic gregorian date, but it is configured to observe the default julian calendar reform date (2299161j) for purposes of calculating month, date and year: Time.new(1582, 10, 4).to_date.to_s # => "1582-09-24" Time.new(1582, 10, 4).to_date.gregorian.to_s # => "1582-10-04" This patch ensures that when the intermediate Date object is advanced to yield a new Date object, that the Time object for return is contructed with a proleptic gregorian month, date and year.
* | Merge pull request #10879 from makaroni4/masterAndrew White2013-07-291-0/+12
|\ \ | | | | | | Added Time#middle_of_day method
| * | Added Time#middle_of_dayAnatoli Makarevich2013-07-281-0/+12
| |/ | | | | | | Added middle_of_day method to Date and DateTime
* | Fix handling of offsets with Time#to_s(:iso8601)Andrew White2013-07-291-1/+3
| | | | | | | | | | | | Use a lambda to ensure that the generated string respects the offset of the time value. Also add DateTime#to_s(:iso8601) and Date#to_s(:iso8601) for completeness.
* | Add Time#to_s(:iso8601) for easy conversion of times to the iso8601 format ↵David Heinemeier Hansson2013-07-281-0/+1
| | | | | | | | for easy Javascript date parsing
* | Return local time for backwards compatibilityAndrew White2013-07-091-8/+25
| |
* | Retain UTC offset when using Time.at_with_coercionAndrew White2013-07-091-0/+33
| | | | | | | | | | | | | | | | | | | | The standard Ruby behavior for Time.at is to return the same type of time when passing an instance of Time as a single argument. Since the an ActiveSupport::TimeWithZone instance may be a different timezone than the system timezone and DateTime just understands offsets the best we can do is to return an instance of Time with the correct offset. Fixes #11350.
* | Fix microsecond precision of Time#at_with_coercionNeer Friedman2013-07-091-0/+4
| | | | | | | | | | | | | | | | When Time.at_with_coercion (wraps Time.at) is called with a single argument that "acts_like?(:time)" it is coerced to integer thus losing it's microsecond percision. This commits changes this to use `#to_f` to prevent the problem
* | Remove deprecated `Time#time_with_datetime_fallback`, `Time#utc_time`Vipul A M2013-07-031-55/+0
| | | | | | | | and `Time#local_time` in favour of `Time#utc` and `Time#local`
* | Override Time.at to work with Time-like valuesAndrew White2013-06-081-0/+22
|/ | | | | | | Time.at allows passing a single Time argument which is then converted to an integer. The conversion code since 1.9.3r429 explicitly checks for an instance of Time so we need to override it to allow DateTime and ActiveSupport::TimeWithZone values.
* Squashed commit of the following:Aaron Patterson2013-05-031-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 2683de5da85135e8d9fe48593ff6167db9d64b18 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:29:20 2013 -0700 cannot support infinite ranges right now commit cebb6acef2c3957f975f6db4afd849e535126253 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:26:12 2013 -0700 reverting infinity comparison commit 385f7e6b4efd1bf9b89e8d607fcb13e5b03737ea Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:23:28 2013 -0700 Revert "Added ability to compare date/time with infinity" This reverts commit 38f28dca3aa16efd6cc3af6453f2e6b9e9655ec1. Conflicts: activesupport/CHANGELOG.md activesupport/lib/active_support/core_ext/numeric/infinite_comparable.rb activesupport/test/core_ext/date_ext_test.rb activesupport/test/core_ext/date_time_ext_test.rb activesupport/test/core_ext/numeric_ext_test.rb activesupport/test/core_ext/time_ext_test.rb activesupport/test/core_ext/time_with_zone_test.rb commit 0d799a188dc12b18267fc8421675729917610047 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:18:53 2013 -0700 Revert "Refactor infinite comparable definition a bit" This reverts commit dd3360e05e4909f2f0c74a624cccc2def688f828. commit 42dec90e49745bbfae546f0560b8783f6b48b074 Author: Aaron Patterson <aaron.patterson@gmail.com> Date: Fri May 3 11:18:47 2013 -0700 Revert "Require 'active_support/core_ext/module/aliasing' in the infinite_comparable module" This reverts commit 7003e71c13c53ec3d34250560fbf80b8381df693.
* Added beginning_of_minute support to core_ext calculations for Time and DateTimeGagan Awhad2013-02-211-0/+8
|
* Standardise the return value of `to_time`Andrew White2013-01-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | This commit standardises the return value of `to_time` to an instance of `Time` in the local system timezone, matching the Ruby core and standard library behavior. The default form for `String#to_time` has been changed from :utc to :local but research seems to suggest the latter is the more common form. Also fix an edge condition with `String#to_time` where the string has a timezone offset in it and the mode is :local. e.g: # Before: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 05:00:00 -0500 # After: >> "2000-01-01 00:00:00 -0500".to_time(:local) => 2000-01-01 00:00:00 -0500 Closes #2453
* Remove assert_nothing_raisedRafael Mendonça França2013-01-031-4/+2
|
* Added ability to compare date/time with infinitybUg2013-01-041-0/+9
| | | | | | | | | | | | | | | | | Date, DateTime, Time and TimeWithZone can now be compared to infinity, so it's now possible to create ranges with one infinite bound and date/time object as another bound. Ex.: @range = Range.new(Date.today, Float::INFINITY) Also it's possible to check inclusion of date/time in range with conversion. Ex.: @range.include?(Time.now + 1.year) # => true @range.include?(DateTime.now + 1.year) # => true Ability to create date/time ranges with infinite bound is required for handling postgresql range types.
* Deprecate obsolete Time to DateTime fallback methodsAndrew White2012-12-111-26/+38
| | | | | | | The Time.time_with_datetime_fallback, Time.utc_time and Time.local_time methods were added to handle the limitations of Ruby's native Time implementation. Those limitations no longer apply so we are deprecating them in 4.0 and they will be removed in 4.1.
* Add #seconds_until_end_of_day to DateTime and TimeOlek Janiszewski2012-11-291-0/+48
|
* Refactored common date and time calculations.Pan Thomakos2012-08-041-175/+7
| | | | | | | | * Added the `DateAndTime::Calculations` module that is included in Time and Date. It houses common calculations to reduce duplicated code. * Simplified and cleaned-up the calculation code. * Removed duplication in tests by adding a behavior module for shared tests. I also added some missing tests.
* Make Time#change work with offsets other than UTC or localAndrew White2012-07-011-0/+31
| | | | | Use Time.new to create times where the current offset is not zero or not in the local time zone - closes #4847 and #6651.
* Add prev_quarter and next_quarter method in Time/Date/DateTimeparanoiase Kang2012-06-201-0/+13
|
* Merge pull request #6376 from jgaskins/timestamp-microsecondsJeremy Kemper2012-05-181-1/+3
|\ | | | | Increase numeric-timestamp precision to nanoseconds
| * Increase `AR#cache_key` precision to nanosecondsJamie Gaskins2012-05-191-1/+3
| |
* | respect nsec in TimeWithZoneVasiliy Ermolovich + Sergey Nartimov2012-05-181-33/+33
| | | | | | | | | | | | | | | | | | | | | | when we pass fractional usec to Time methods we should use Rational instead of Float because of accuracy problem Time.local(2011,6,12,23,59,59,999999.999).nsec # => 999999998 Time.local(2011,6,12,23,59,59,Rational(999999999, 1000)).nsec # => 999999999
* | wrap time ranges with timezones, closes #6179Vasiliy Ermolovich2012-05-171-1/+9
|/
* added beginning_of_hour support to core_ext calculations for Time and DateTimeMark J. Titorenko2012-05-041-0/+8
|
* Merge pull request #4284 from mattdbridges/time_calculation_aliasesXavier Noria2012-02-281-0/+18
|\ | | | | Added aliases for prev_year, prev_month, and prev_week in Time and Date calculations
| * Adding :last_week, :last_month, and :last_year aliases to Time and DateMatt Bridges2012-02-211-0/+18
| | | | | | | | core extensions
* | Optional start_day argument for Time#all_week.kennyj2012-02-061-0/+1
| | | | | | | | Closes #4883
* | Deprecate DateTime.local_offsetbrainopia2012-01-251-4/+4
|/
* use AS::TestCase as the base classAaron Patterson2012-01-051-1/+1
|
* Nano seconds fraction of time is copied properly in Time#advancePawel Pierzchala2012-01-051-0/+5
| | | | | | When day, month or year was passed, advance created a new time ignoring previous nsec fraction. Now nsec is passed through usec as a Rational number.
* beginning_of_week extended in both Time and Date so that to return week ↵gregolsen2011-11-251-0/+20
| | | | start based on start day that is monday by default
* Merge pull request #3725 from marcandre/twz_eqlYehuda Katz2011-11-221-0/+6
|\ | | | | Fix inconsistencies with Time{WithZone}#{hash,eql?}
| * Fix inconsistencies with Time{WithZone}#{hash,eql?}Marc-Andre Lafortune2011-11-221-0/+6
| |
* | Removed argument throwing warnings when running tests.Henrik Hodne2011-11-061-13/+13
|/ | | | | | | | The last argument to DateTime.new/civil is the Julian day number for when the calendar reform occured. DateTime ignores it if it's 0, and sets it to the default of DateTime::ITALY instead, so we could just leave it out. This also removes the warnings while running the ActiveSupport tests (there still are some for the setup though).
* Add tests for fixes to Time.===Jeremy Evans2011-09-071-0/+3
|
* Rename Time#whole_* to Time#all_* [thanks Pratik!]David Heinemeier Hansson2011-06-131-10/+10
|
* Added Time#whole_day/week/quarter/year as a way of generating ranges ↵David Heinemeier Hansson2011-06-131-0/+20
| | | | (example: Event.where(created_at: Time.now.whole_week)) [DHH]
* Fix marshal round-tripping of fractional seconds (Time#subsec).Jason Weathered2011-04-171-0/+7
|
* reverted tests deleted by 080345baca1076a9788d, refactored implementations ↵Diego Carrion2011-03-041-3/+13
| | | | | | should not invalidate the validations Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Ruby 1.8.7+ provides to_date/to_datetime, AS just makes them public.John Firebaugh2011-02-031-13/+3
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* implements weeks_ago and prev_week for Date/DateTime/Time [#5122 ↵Rob Zolkos & Xavier Noria2010-10-161-0/+18
| | | | state:committed]
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-10/+10
| | | | 's/[ \t]*$//' -i {} \;)
* removes deprecations of last_(month|year) from master, they will be ↵Xavier Noria2010-05-191-8/+0
| | | | deprecated in 2.3 instead
* defines prev_(month|year) in Date and Time to ease transition to 1.9, and ↵Xavier Noria2010-05-121-5/+13
| | | | deprecates last_(month|year)
* let Time.time_with_datetime_fallback handle properly years in the range 0..138Xavier Noria2010-05-051-0/+7
|
* Ruby 1.9.2: marshaling round-trips Time#zoneJeremy Kemper2010-03-281-12/+8
|
* Time zone tests were right all along.José Valim2010-03-281-4/+4
|
* Ruby's marshaling of Time instances doesn't respect the zone [#4282 ↵Santiago Pastorino2010-03-271-2/+2
| | | | | | state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>