aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_with_zone_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Removed mocha stubbing in active_supportRonak Jangir2015-06-071-28/+35
|
* Improve ActiveSupport::TimeWithZone conversion to YAMLAndrew White2015-04-221-2/+45
| | | | | | | | | | | Previously when converting AS::TimeWithZone to YAML it would be output as a UTC timestamp. Whilst this preserves the time information accurately it loses the timezone information. This commit changes that so that it is saved along with the time information. It also provides nicer encoding of AS::TimeZone instances themselves which previously embedded all of the data from the TZInfo records. Fixes #9183.
* Revert "Take DST into account when locating TimeZone from Numeric."Andrew White2015-03-091-7/+0
| | | | | | | | | | | | | | | | Reverting this as it's not the implementation that we would like it to be. This is being used inside of ActiveSUpport::TimeZone[] and it's unaware of the context in which to find the timezone period so the timezone found changes depending on whether DST is in effect for the current period. This means that `'2001-01-01'.in_time_zone(-9)` changes from winter/summer even though it's the same date that we're trying to convert. Since finding timezones by numeric offsets is a bit hit and miss we should introduce a new API for finding them which supplies the date context in which we want to search and we should probably also deprecate the finding of timezones via the [] method, though this needs further discussion. This reverts commit 2cc2fa3633edd96773023c6b09d07c7b9d9b841d.
* Take DST into account when locating TimeZone from Numeric.Yasyf Mohamedali2015-03-031-0/+7
| | | | | | When given a specific offset, use the first result found where the total current offset (including any periodic deviations such as DST) from UTC is equal.
* Merge pull request #16749 from robin850/rbx-name-errorRafael Mendonça França2015-01-021-0/+2
|\ | | | | Rely on NameError#name instead of its error message
| * Skip an error message related assertion on RubiniusRobin Dupret2014-10-281-0/+2
| | | | | | | | | | | | Rubinius' error messages don't call `#inspect` on the concerned object while the assertion is here to address a wrong inspection on MRI with time zones so let's keep this test for now on Rubinius.
* | Optimize TimeWithZoneTest#strftimePablo Herrero2014-10-271-0/+5
|/
* missing activesupport test coverageEugene Gilburg2014-07-191-0/+1
|
* Extract out with_env_tz helper method.Zuhao Wan2014-06-181-50/+12
| | | | | It’s used at so many places that extracting it out into a helper file is worth doing.
* Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lostGordon Chan2014-05-301-0/+15
| | | | | | | | | | | | | | | | | | | | When working with objects with a nanosecond component, the `-` method may unnecessarily cause loss of precision. `ActiveSupport::TimeWithZone#-` should return the same result as if we were using `Time#-`: Time.now.end_of_day - Time.now.beginning_of_day #=> 86399.999999999 Before: Time.zone.now.end_of_day.nsec #=> 999999999 Time.zone.now.end_of_day - Time.zone.now.beginning_of_day #=> 86400.0 After: Time.zone.now.end_of_day - Time.zone.now.beginning_of_day #=> 86399.999999999
* Maintain the current timezone in wrap_with_time_zoneAndrew White2014-01-311-0/+5
| | | | | | | Extend the solution from the fix for #12163 to the general case where `Time` methods are wrapped with a time zone. Fixes #12596.
* Make ActiveSupport::TimeWithZone#xmlschema consistentAndrew White2014-01-261-0/+4
| | | | | | Both Time#xmlschema and DateTime#xmlschema can accept nil values for the fraction_digits parameter. This commit makes this so for TimeWithZone values as well.
* Consolidate JSON encoding tests in one fileAndrew White2014-01-261-35/+0
|
* Customize subsecond digits when encoding DateWithTimeParker Selbert2014-01-261-7/+22
| | | | | | | | | | | The subsecond fraction digits had been hardcoded to 3. This forced all timestamps to include the subsecond digits with no way to customize the value. While the subsecond format is part of the ISO8601 spec, it is not adhered to by all parsers (notably mobile clients). This adds the ability to customize the number of digits used, optionally setting them to 0 in order to eliminate the subsecond fraction entirely: ActiveSupport::JSON::Encoding.subsecond_fraction_digits = 0
* Maintain current timezone when changing time during DST overlapAndrew White2014-01-261-0/+5
| | | | | | | | | | | | | | Currently if a time is changed during DST overlap in the autumn then the method `period_for_local` will return the DST period. However if the original time is not DST then this can be surprising and is not what is generally wanted. This commit changes that behavior to maintain the current period if it's in the list of periods returned by `periods_for_local`. It is possible to alter the behavior of `period_for_local` by specifying a second argument but since we may be change from another time that could be either DST or not then this would give inconsistent results. Fixes #12163.
* Fix unused variable warningAndrew White2013-08-041-0/+1
| | | | | | We need to call `in_time_zone` to test that it isn't modifying the receiver but since the variable isn't used it raises a warning so add an assertion to make Ruby think it's being used.
* Refactor Date, Time, DateTime timezone methodsGilad Zohari2013-08-011-0/+8
| | | | | | Similar implementations of #in_time_zone exists for Date, Time and DateTime so method is extracted into its own module. Also some logic is extracted into private method.
* Add failing test for #9562Andrew White2013-07-101-0/+5
| | | | | | | | Rails 4.0.0 fails when trying to encode an ActiveSupport::TimeWithZone that wraps a DateTime instance. This is fixed on master so add a test to prevent regression. (cherry picked from commit ad01b8da354268cebfae1519c28d19d75576ccb1)
* Add missing nsec test for 17f5d8eAndrew White2013-06-131-0/+5
|
* Keep sub-second resolution when wrapping a DateTime valueAndrew White2013-06-131-0/+5
| | | | | | | Add `DateTime#usec` and `DateTime#nsec` so that `ActiveSupport::TimeWithZone` keeps sub-second resolution when wrapping a `DateTime` value. Fixes #10855
* Squashed commit of the following:Aaron Patterson2013-05-031-10/+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.
* `TimeWithZone` raises `NoMethodError` in proper context.Yves Senn2013-03-181-0/+8
| | | | | | | | | Closes #9772. `TimeWithZone` delegates everything to the wrapped `Time` object using `method_missing`. The result is that `NoMethodError` error will be raised in the context of `Time` which leads to a misleading debug output.
* Added `ActiveSupport::TimeWithZone#to_r` for `Time#at` compatibility.stopdropandrew2013-02-241-0/+11
|
* Added beginning_of_minute support to core_ext calculations for Time and DateTimeGagan Awhad2013-02-211-0/+14
|
* Modify TimeWithZone#as_json to return 3DP of sub-second accuracy by default, ↵James Harton2013-01-311-1/+1
| | | | since it's allowed by the spec and is very useful.
* 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/+12
| | | | | | | | | | | | | | | | | 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.
* Beef up tests for String#in_time_zone and Date#in_time_zoneAndrew White2012-12-111-0/+128
|
* respect nsec in TimeWithZoneVasiliy Ermolovich + Sergey Nartimov2012-05-181-0/+8
| | | | | | | | | | | 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
* Merge pull request #6169 from marcandre/respond_to_missingJosé Valim2012-05-051-0/+1
|\ | | | | Respond to missing
| * Use respond_to_missing for TimeWithZoneMarc-Andre Lafortune2012-05-051-0/+1
| |
* | Merge pull request #6156 from mjtko/feature-beginning_of_hourJeremy Kemper2012-05-041-0/+14
|\ \ | | | | | | Beginning and end of hour support for Time and DateTime
| * | added beginning_of_hour support to core_ext calculations for Time and DateTimeMark J. Titorenko2012-05-041-0/+14
| |/
* / enable tests for beginning_of_* and end_of_* within time zone tests; enable ↵Mark J. Titorenko2012-05-041-8/+8
|/ | | | test for future_with_time_current_as_time_with_zone; fix beginning_of_month test.
* use AS::TestCase as the base classAaron Patterson2012-01-051-2/+2
|
* Initial pass at removing dead 1.8.x code from Active Support.José Valim2011-12-201-2/+1
| | | | | | There are a bunch of other implicit branches that adds 1.8.x specific code that still needs to be removed. Pull requests for those cases are welcome.
* Fix inconsistencies with Time{WithZone}#{hash,eql?}Marc-Andre Lafortune2011-11-221-2/+9
|
* Fix xmlschema output with fraction_digits >0shtirlic2011-07-111-0/+7
| | | | | Current implementation produce incorrect output when Time#usec returns integer < 100000, because to_s doesn't add leading zeros.
* added find_zone and find_zone! to AS timezones and changed the AS Railtie to ↵Josh Kalderimis2011-04-051-0/+18
| | | | | | use find_zone! as well as adding Railtie tests Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Raise on invalid timezoneMarc-Andre Lafortune2011-04-051-5/+26
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* updated Time, Date and DateTime current methods in AS to use Time.zone and ↵Josh Kalderimis2011-02-281-7/+8
| | | | | | not Time.zone_default. [#6410 state:committed]
* prefering psych as the yaml parser if possible, fixing assertions for YAML ↵Aaron Patterson2011-01-211-2/+2
| | | | 1.1 compatibility
* make our yaml output consistentAaron Patterson2011-01-041-1/+1
|
* Fix ActiveSupport::TimeWithZone#localtime method with DateTimeAlvaro Bautista2010-11-111-0/+11
| | | | | | [#5344 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-3/+3
| | | | 's/[ \t]*$//' -i {} \;)
* Don't store incorrect values in zones_mapSantiago Pastorino2010-06-281-3/+1
| | | | | | [#4942 state:committed] Signed-off-by: José Valim <jose.valim@gmail.com>
* when the timezone is nil, a TimeWithZone object should not be constructed. ↵Aaron Patterson2010-06-171-0/+7
| | | | | | [#4881 state:resolved] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Fix test incorrectly using a bare assert to use assert_kind_ofSantiago Pastorino2010-05-241-1/+1
| | | | Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Final iteration of use better testing methodsNeeraj Singh2010-05-191-6/+6
| | | | | | [#4652 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>