Skip to content

Commit

Permalink
Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985
Browse files Browse the repository at this point in the history
 [dave@cherryville.org]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1063 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Apr 2, 2005
1 parent f84044a commit c6cc707
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN* *SVN*


* Fixed auto-stamping of dates (created_on/updated_on) for PostgreSQL #985 [dave@cherryville.org]

* Fixed Base.silence/benchmark to only log if a logger has been configured #986 [skaes@web.de] * Fixed Base.silence/benchmark to only log if a logger has been configured #986 [skaes@web.de]


* Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [skaes@web.de] * Added a join parameter as the third argument to Base.find_first and as the second to Base.count #426, #988 [skaes@web.de]
Expand Down
Expand Up @@ -205,22 +205,22 @@ def binary_to_string(value)


private private
def string_to_date(string) def string_to_date(string)
return string if string.is_a?(Date) return string unless string.is_a?(String)
date_array = ParseDate.parsedate(string) date_array = ParseDate.parsedate(string.to_s)
# treat 0000-00-00 as nil # treat 0000-00-00 as nil
Date.new(date_array[0], date_array[1], date_array[2]) rescue nil Date.new(date_array[0], date_array[1], date_array[2]) rescue nil
end end


def string_to_time(string) def string_to_time(string)
return string if string.is_a?(Time) return string unless string.is_a?(String)
time_array = ParseDate.parsedate(string).compact time_array = ParseDate.parsedate(string.to_s).compact
# treat 0000-00-00 00:00:00 as nil # treat 0000-00-00 00:00:00 as nil
Time.send(Base.default_timezone, *time_array) rescue nil Time.send(Base.default_timezone, *time_array) rescue nil
end end


def string_to_dummy_time(string) def string_to_dummy_time(string)
return string if string.is_a?(Time) return string unless string.is_a?(String)
time_array = ParseDate.parsedate(string) time_array = ParseDate.parsedate(string.to_s)
# pad the resulting array with dummy date information # pad the resulting array with dummy date information
time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1; time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1;
Time.send(Base.default_timezone, *time_array) rescue nil Time.send(Base.default_timezone, *time_array) rescue nil
Expand Down

0 comments on commit c6cc707

Please sign in to comment.