GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of halorgium/mephisto
Description: A refactored Mephisto that has multiple spam detection engines.
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/francois/mephisto.git
francois (author)
Mon Mar 17 19:02:47 -0700 2008
commit  cf11753a6d59fbbfcbd0e063706395ff31600059
tree    99cad4a4e7cbdd79c3c9781008d0ee9d0cbc4451
parent  f1068ff008b7da9263fd9037d1a37b3813e70991
mephisto / lib / xmlrpc_patch.rb
100644 43 lines (43 sloc) 1.577 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module XMLRPC
  module Convert
    def self.dateTime(str)
      case str
      when /^(-?\d\d\d\d)-?(\d\d)-?(\d\d)T(\d\d):(\d\d):(\d\d)(?:Z|([+-])(\d\d):?(\d\d))?$/
        a = [$1, $2, $3, $4, $5, $6].collect{|i| i.to_i}
        if $7
          ofs = $8.to_i*3600 + $9.to_i*60
          ofs = -ofs if $7=='+'
          # Ruby's original method call has Time.utc(a.reverse) here
          # which totally doesn't make sense since a) Time#utc doesn't take
          # an array as its argument and b) year is the first argument, so
          # why reverse it?
          utc = Time.utc(*a) + ofs
          # END OF PATCH
          a = [ utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec ]
        end
        XMLRPC::DateTime.new(*a)
      when /^(-?\d\d)-?(\d\d)-?(\d\d)T(\d\d):(\d\d):(\d\d)(Z|([+-]\d\d):(\d\d))?$/
        a = [$1, $2, $3, $4, $5, $6].collect{|i| i.to_i}
        if a[0] < 70
          a[0] += 2000
        else
          a[0] += 1900
        end
        if $7
          ofs = $8.to_i*3600 + $9.to_i*60
          ofs = -ofs if $7=='+'
          # Ruby's original method call has Time.utc(a.reverse) here
          # which totally doesn't make sense since a) Time#utc doesn't take
          # an array as its argument and b) year is the first argument, so
          # why reverse it?
          utc = Time.utc(*a) + ofs
          # END OF PATCH
          a = [ utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec ]
        end
        XMLRPC::DateTime.new(*a)
      else
        raise "wrong dateTime.iso8601 format " + str
      end
    end
  end
end