aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time/conversions.rb
Commit message (Collapse)AuthorAgeFilesLines
* [Active Support] require => require_relativeAkira Matsuda2017-07-011-4/+4
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-6/+6
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-5/+5
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Update docs for `formatted_offset` Ronak Jangir2015-09-291-0/+2
| | | Output of `formatted_offset` is depends on input so it’s not always in +HH:MM format. Possible outputs are “+5:30”, “+530” or provided alternate UTC string [ci skip]
* `DateTime#to_f` now preserves fractional seconds.John Paul Ashenfelter2014-07-021-2/+2
| | | | | | | Previously this method always returns `.0` in the fractional part. This commit changes it to preserve the fractional seconds instead. Fixes #15994.
* Fix handling of offsets with Time#to_s(:iso8601)Andrew White2013-07-291-0/+1
| | | | | | 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.
* Keep sub-second resolution when wrapping a DateTime valueAndrew White2013-06-131-0/+10
| | | | | | | Add `DateTime#usec` and `DateTime#nsec` so that `ActiveSupport::TimeWithZone` keeps sub-second resolution when wrapping a `DateTime` value. Fixes #10855
* Fixes Dependency bug in Active SupportTomohiko Himura2013-05-021-0/+1
| | | | DateTime defined in date.rb
* update AS/core_ext docs [ci skip]Francesco Rodriguez2012-09-121-3/+4
|
* Improve performance of DateTime#seconds_since_unix_epochAndrew White2012-07-021-2/+5
| | | | | | | | | | | | | | | | | | | Calculate the seconds since the UNIX epoch using the difference in Julian day numbers from the epoch date. By reducing the Rational math to just the offset component this gives a significant improvement. Benchmark: Calculating -------------------------------------------- new 27733 i/100ms current 15031 i/100ms new 27737 i/100ms current 15549 i/100ms -------------------------------------------------------- new 548182.1 (±0.9%) i/s - 2745567 in 5.008943s current 216380.9 (±1.6%) i/s - 1082232 in 5.002781s new 510281.9 (±1.2%) i/s - 2551804 in 5.001525s current 219858.3 (±1.8%) i/s - 1103979 in 5.023039s
* Revert "Use strftime to convert DateTime to numeric"Andrew White2012-07-011-1/+2
| | | | | | | There appears to be a bug with DateTime#strftime("%s") on 32-bit platforms. Bug report: http://bugs.ruby-lang.org/issues/6683 This reverts commit 210cd756a628cc19c0d6e44bee8c33dfb2d9d598.
* Remove DateTime#to_time overrideAndrew White2012-07-011-14/+0
| | | | | | | | Currently if the offset is not zero then to_time returns self which can lead to errors where a developer assumes that the value is a Time. To solve this we can use the native implementation of DateTime#to_time in Ruby 1.9.3 as it handles offsets properly and is faster than our override.
* Use strftime to convert DateTime to numericAndrew White2012-07-011-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The native implementation of the seconds since the UNIX epoch in strftime is significantly faster than our method. Benchmark: ---------- require 'benchmark/ips' require 'date' require 'time' date = DateTime.civil(1253,7,6,20,4,0) Benchmark.ips do |x| x.report("strftime.to_i") { date.strftime('%s').to_i } x.report("ssue.to_i") { ((date - DateTime.civil(1970)) * 86400).to_i } x.report("strftime.to_f") { date.strftime('%s').to_f } x.report("ssue.to_f") { ((date - DateTime.civil(1970)) * 86400).to_f } end Output: ------- Calculating ------------------------------------- strftime.to_i 26480 i/100ms ssue.to_i 13818 i/100ms strftime.to_f 26561 i/100ms ssue.to_f 14479 i/100ms ------------------------------------------------- strftime.to_i 616937.3 (±2.4%) i/s - 3098160 in 5.024749s ssue.to_i 200108.8 (±6.9%) i/s - 994896 in 4.999278s strftime.to_f 553581.3 (±2.2%) i/s - 2788905 in 5.040397s ssue.to_f 204260.3 (±4.3%) i/s - 1028009 in 5.043072s
* stop `to_s`ing method namesAkira Matsuda2012-06-061-1/+1
| | | | Module#methods are Symbols in Ruby >= 1.9
* removing unnecessary 'examples' noise from activesupportFrancesco Rodriguez2012-05-131-1/+0
|
* String quotes and trailing spacesAlexey Gaziev2012-04-291-1/+1
|
* AS core_ext refactoring pt.2Alexey Gaziev2012-04-291-1/+5
|
* Deprecate DateTime.local_offsetbrainopia2012-01-251-1/+11
|
* remove ruby 1.8 related codeVasiliy Ermolovich2012-01-181-15/+0
|
* remove condition since to_time always available in ruby19 DateTimeVishnu Atrai2011-12-311-1/+1
|
* Initial pass at removing dead 1.8.x code from Active Support.José Valim2011-12-201-1/+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 punctuation errors.Sebastian Martinez2011-05-041-8/+8
|
* Preserve fractional seconds in DateTime#to_timeJohn Firebaugh2011-02-031-1/+1
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* In AS, only inflector/methods is need in proxy_wrappers.rb, as well as date, ↵Josh Kalderimis2011-01-121-1/+1
| | | | | | date_time, and time conversions.rb. This fixes an issue when requiring json and AS saying that i18n is also required. Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-6/+6
| | | | 's/[ \t]*$//' -i {} \;)
* Refactor move some date, time and date_time methods to */zones and fixed ↵Santiago Pastorino2010-07-031-0/+1
| | | | some requires
* fix conditions when DateTime#to_date and DateTime#xmlschema methods are definedRaimonds Simanovskis2010-06-041-3/+3
|
* let Time.time_with_datetime_fallback handle properly years in the range 0..138Xavier Noria2010-05-051-0/+6
|
* AS datetime conversions now require AS time conversionssnusnu2010-03-181-0/+1
|
* Added #to_i to DateTime in ActiveSupport so #to_yaml works correctly on ↵Serguei Filimonov2009-12-151-2/+13
| | | | ActiveRecord models with DateTime attributes.
* Check for date/time methods that moved upstream in 1.9Jeremy Kemper2009-05-071-3/+3
|
* Convert DateTime extensions to class reopensJeremy Kemper2009-03-281-87/+75
|
* Move Numeric#to_utc_offset_s to TimeZone.seconds_to_utc_offsetJeremy Kemper2009-03-231-1/+1
|
* Merge docrailsPratik Naik2009-01-181-1/+1
|
* Ruby 1.8.7 compat: detect and alias non-superclass DateTime#to_sJeremy Kemper2008-04-201-4/+9
|
* Improve documentation.Pratik Naik2008-04-051-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9226 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fine, warn. Just don't recurse to death in cc.rbJeremy Kemper2008-03-311-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9161 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Always alias DateTime#to_s to #to_default_sJeremy Kemper2008-03-311-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9155 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Play nice with 1.9's DateTime#to_sJeremy Kemper2008-03-291-1/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9137 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Adding TimeZone#at and DateTime#to_fGeoff Buesing2008-03-171-0/+6
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9042 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Remove unneeded #to_datetime_default_s alias for DateTime#to_s, given that ↵Geoff Buesing2008-01-231-1/+0
| | | | | | we inherit a #to_default_s from Date that does exactly the same thing git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8705 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Refactor Time and DateTime #to_formatted_s: use ternary instead of nested ↵Geoff Buesing2008-01-231-9/+2
| | | | | | if/else git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8699 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Adding Time and DateTime #formatted_offset, for outputting +HH:MM utc offset ↵Geoff Buesing2008-01-231-0/+9
| | | | | | strings with cross-platform consistency git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8698 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Simplify to_formatted_s docs. Closes #10747 [Jeremy Kemper]Jeremy Kemper2008-01-091-26/+14
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8608 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Document date and time to_formatted_s. Closes #10747 [leethal]Jeremy Kemper2008-01-091-2/+23
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8606 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Docfix (closes #10369) [revans]David Heinemeier Hansson2007-12-171-1/+17
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8428 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Ruby 1.9 compat: normalize date and time xmlschema to match Ruby's ↵Jeremy Kemper2007-12-151-4/+8
| | | | | | formatting [chuyeow] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8398 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Cater for DST changes when converting Times to DateTimes. Closes #10068 ↵Michael Koziarski2007-11-051-3/+2
| | | | | | [gbuesing] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8076 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed Date#xmlschema for dates outside the range of what can be created with ↵David Heinemeier Hansson2007-10-011-0/+4
| | | | | | Time (closes #9744) [gbuesing] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7707 5ecf4fe2-1ee6-0310-87b1-e25e094e27de