aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/string/conversions.rb
Commit message (Collapse)AuthorAgeFilesLines
* [Active Support] require_relative => requireAkira Matsuda2017-10-211-1/+1
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-011-1/+1
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-2/+2
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Add compatibility for Ruby 2.4 `to_time` changesAndrew White2016-04-231-1/+1
| | | | | | | | | | | | | | | In Ruby 2.4 the `to_time` method for both `DateTime` and `Time` will preserve the timezone of the receiver when converting to an instance of `Time`. Since Rails 5.0 will support Ruby 2.2, 2.3 and later we need to introduce a compatibility layer so that apps that upgrade do not break. New apps will have a config initializer file that defaults to match the new Ruby 2.4 behavior going forward. For information about the changes to Ruby see: https://bugs.ruby-lang.org/issues/12189 https://bugs.ruby-lang.org/issues/12271 Fixes #24617.
* Match `String#to_time`'s behaviour to rubySiim Liiser2016-04-041-1/+2
| | | | | | | | Previously `String#to_time` returned the midnight of the current date in some cases where there was no relavant information in the string. Now the method returns `nil` instead in those cases. Fixes #22958.
* Fixed Time conversion example for UTC time zone [ci skip]Ronak Jangir2015-09-081-1/+1
|
* Change syntax format for example returned valuesPrem Sichanugrist2013-11-111-8/+8
| | | | | | | | | According to our guideline, we leave 1 space between `#` and `=>`, so we want `# =>` instead of `#=>`. Thanks to @fxn for the suggestion. [ci skip]
* document String#to_time exceptionVipul A M2013-05-021-0/+1
|
* Adjust for daylight savings in String#to_timeAndrew White2013-04-231-8/+6
| | | | | | | | | | | | | | | The changes in b79adc4323 had a bug where if the time in the String was in standard time but the current time was in daylight savings then the calculated adjustment was off by an hour. This commit fixes this and adds extra tests for the following: * time in string is standard time, current time is standard time * time in string is standard time, current time is daylight savings * time in string is daylight savings, current time is standard time * time in string is daylight savings, current time is daylight savings Fixes #10306.
* Use `DateTime.parse` inside `String#to_datetime`Andrew White2013-01-211-8/+1
| | | | | | | | | | Use the standard library's `DateTime.parse` because it's marginally faster and supports partial date/time strings. Benchmark: user system total real old 3.980000 0.000000 3.980000 ( 3.987606) new 3.640000 0.010000 3.650000 ( 3.641342)
* Standardise the return value of `to_time`Andrew White2013-01-211-17/+27
| | | | | | | | | | | | | | | | | | | | | | 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
* Better error message for String#to_dateKelly Stannard2013-01-041-5/+1
| | | | | | | | | | I did this because to_date gives a very unhelpful error message if you do not pass in a correct date. In the process I think this cleans up the code nicely and even better it tends to be slightly faster than the current implementation. Benchmark https://gist.github.com/4440875
* Deprecate obsolete Time to DateTime fallback methodsAndrew White2012-12-111-1/+1
| | | | | | | 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.
* String.to_time documentation along examples.Adam Stankiewicz2012-09-241-1/+11
|
* removing trailing spacesFrancesco Rodriguez2012-05-111-3/+3
|
* added docs to String#to_datetimeFrancesco Rodriguez2012-05-111-0/+6
|
* added docs to String#to_dateFrancesco Rodriguez2012-05-111-0/+6
|
* AS core_ext refactoringAlexey Gaziev2012-04-291-10/+22
|
* no more need to make Time#to_date and Time#to_datetime publicSergey Nartimov2011-12-221-1/+0
| | | | they are public in actual 1.9 ruby version (tested at least in 1.9.2-p180)
* remove support for ruby 1.8 in AS String extensionsSergey Nartimov2011-12-211-29/+0
|
* adds a couple of missing magic comments [fixes #1374]Xavier Noria2011-07-231-0/+1
|
* Make String.to_time respect timezonesNate Mueller2011-06-021-2/+2
|
* Implemented getbyte as an aliased method and RDoc addedSantiago Pastorino2010-06-281-3/+2
| | | | Signed-off-by: Xavier Noria <fxn@hashref.com>
* Makes more sense to ask about method_defined?Santiago Pastorino2010-06-281-1/+1
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Added getbyte as a core_ext to Ruby < 1.9Santiago Pastorino2010-06-271-0/+4
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Move constantize from conversions to inflections.Santiago Pastorino2010-06-261-11/+0
| | | | | | | | This removes ActiveModel dependency on TZInfo. [#4979 state:committed] Signed-off-by: José Valim <jose.valim@gmail.com>
* ActiveSupport::Dependencies.constantize shortcut for caching named constant ↵Jeremy Kemper2010-06-051-0/+11
| | | | lookups
* updates String#to_(date|date_time|time) to return nil for blank stringsDaniel Neighman2010-04-211-0/+3
|
* much complete rdoc for String#ordXavier Noria2010-04-191-3/+19
|
* revises the rdoc of String#ordXavier Noria2010-04-191-1/+5
|
* require publicize_conversion_method to ensure to_date and to_datetime became ↵Santiago Pastorino2010-02-191-0/+1
| | | | public before redefining them (avoid warnings)
* String #to_time and #to_datetime: handle fractional seconds [#864 ↵Jason Frey (Fryguy)2009-06-071-2/+6
| | | | state:resolved]
* Prefer behavior check to RUBY_VERSION to catch 1.8 backportsJeremy Kemper2009-04-291-1/+1
|
* Fix dependencies revealed by testing in isolationJeremy Kemper2009-04-221-0/+1
|
* Convert String conversions, filters, starts/ends_with, and multibyte ↵Jeremy Kemper2009-03-281-21/+14
| | | | extension modules to class reopen
* Ruby 1.9 compat: don't use obsolete ParseDateJeremy Kemper2007-12-271-4/+4
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8490 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Ruby 1.9 compat: 'a'.ord == 'a'[0]Jeremy Kemper2007-12-151-2/+7
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8403 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Honor Ruby's default calendar reform setting when creating DateTime objects ↵Geoff Buesing2007-11-241-1/+1
| | | | | | via ActiveRecord's Time -> DateTime overflow, Time#time_with_datetime_fallback, Time#to_datetime, Date#to_datetime and String#to_datetime. Closes #10201 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8199 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* String#to_time overflows to DateTime. Add String#to_datetime. Closes #8572.Jeremy Kemper2007-06-041-1/+5
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6935 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added String#to_time and String#to_date for wrapping ParseDateDavid Heinemeier Hansson2005-03-021-0/+19
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@824 5ecf4fe2-1ee6-0310-87b1-e25e094e27de