This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 5697e596 DateTime is deprecated
5697e596 is described below

commit 5697e596020e6ffb92cdd70d25a9903bb5837680
Author: Sebb <[email protected]>
AuthorDate: Sun Feb 12 23:16:10 2023 +0000

    DateTime is deprecated
---
 lib/whimsy/asf/svn.rb                    | 4 ++--
 lib/whimsy/logparser.rb                  | 7 ++++---
 tools/collate_minutes.rb                 | 3 +--
 tools/mboxhdr2csv.rb                     | 6 +++---
 www/members/board-nominations.cgi        | 3 ++-
 www/members/nominations.cgi              | 3 ++-
 www/officers/coi.cgi                     | 7 +++----
 www/roster/views/actions/memstat.json.rb | 2 +-
 8 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index 0d1981a9..03b1f296 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -939,7 +939,7 @@ module ASF
             list = self.list(url, user, password, storedates)
             if storedates
               require 'nokogiri'
-              require 'date'
+              require 'time'
               open(listfiletmp, 'w') do |w|
                 w.puts "#{EPOCH_TAG}#{svnrev}" # show that this file has epochs
                 xml_doc = Nokogiri::XML(list)
@@ -947,7 +947,7 @@ module ASF
                   kind = entry.css('@kind').text
                   name = entry.at_css('name').text
                   date = entry.at_css('date').text
-                  epoch = DateTime.parse(date).strftime('%s')
+                  epoch = Time.parse(date).strftime('%s')
                   # The separator is the last character of the epoch tag
                   w.puts "%s#{EPOCH_SEP}%s%s" % [epoch, name, kind == 'dir' ? 
'/' : '']
                 end
diff --git a/lib/whimsy/logparser.rb b/lib/whimsy/logparser.rb
index 0c743be3..040a5d7c 100755
--- a/lib/whimsy/logparser.rb
+++ b/lib/whimsy/logparser.rb
@@ -6,6 +6,7 @@ require 'whimsy/asf'
 require 'json'
 require 'stringio'
 require 'zlib'
+require 'time'
 
 # Utility methods to turn server logs into hashes of interesting data
 module LogParser
@@ -152,11 +153,11 @@ module LogParser
           last_time = $1
           capture = $2
           if capture =~ /Passenger/
-            logs[DateTime.parse(last_time).iso8601(TRUNCATE)] = capture
+            logs[Time.parse(last_time).iso8601(TRUNCATE)] = capture
           end
         elsif (l =~ /(_ERROR|_WARN  (.+)whimsy)/) && l !~ ignored
           # Offset our time so it doesn't overwrite any Passenger entries
-          (logs[(DateTime.parse(last_time) + 1 / 
TIME_OFFSET).iso8601(TRUNCATE)] ||= []) << l
+          (logs[(Time.parse(last_time) + 1 / TIME_OFFSET).iso8601(TRUNCATE)] 
||= []) << l
         end
       rescue StandardError => e
         puts e
@@ -190,7 +191,7 @@ module LogParser
       r.match(l) do |m|
         unless ignored =~ m[2]
           begin
-            logs[DateTime.parse(m[1]).iso8601(6)] = m[2]
+            logs[Time.parse(m[1]).iso8601(6)] = m[2]
           rescue StandardError
             # Fallback to merely using the string representation
             logs[m[1]] = m[2]
diff --git a/tools/collate_minutes.rb b/tools/collate_minutes.rb
index 81603ee3..c506b9c5 100755
--- a/tools/collate_minutes.rb
+++ b/tools/collate_minutes.rb
@@ -2,7 +2,6 @@
 $LOAD_PATH.unshift '/srv/whimsy/lib'
 
 require 'whimsy/asf'
-require 'date'
 require 'builder'
 require 'ostruct'
 require 'nokogiri'
@@ -44,7 +43,7 @@ NOSTAMP = ARGV.delete '--nostamp' # don't add dynamic 
timestamp to pages (for de
 
 DUMP_AGENDA = ARGV.delete '--dump_agenda' # output agenda details
 
-STAMP = (NOSTAMP ? DateTime.new(1970) :  DateTime.now).strftime '%Y-%m-%d 
%H:%M'
+STAMP = (NOSTAMP ? Time.new(1970) :  Time.now).strftime '%Y-%m-%d %H:%M'
 
 YYYYMMDD = ARGV.shift || '20*' # Allow override of minutes to process
 
diff --git a/tools/mboxhdr2csv.rb b/tools/mboxhdr2csv.rb
index cd1807df..c6babc78 100644
--- a/tools/mboxhdr2csv.rb
+++ b/tools/mboxhdr2csv.rb
@@ -15,7 +15,7 @@ require 'csv'
 require 'stringio'
 require 'zlib'
 require 'json'
-require 'date'
+require 'time'
 require 'optparse'
 
 # Various utility functions/data for mailing list analysis
@@ -186,7 +186,7 @@ module MailUtils
       next if email.end_with? '/index'
       message = IO.read(email, mode: 'rb')
       data = {}
-      data[DATE] = DateTime.parse(message[/^Date: (.*)/, 1]).iso8601
+      data[DATE] = Time.parse(message[/^Date: (.*)/, 1]).iso8601
       data[FROM] = message[/^From: (.*)/, 1]
       # Originally (before 2265343) the local method #find_who_from expected 
an email address and returned who, committer
       # Emulate this with the version from MailUtils which expects and updates 
a hash
@@ -327,7 +327,7 @@ module MboxUtils
         # Annotate various other precomputable data
         MailUtils.find_who_from(mdata)
         begin
-          d = DateTime.parse(mdata[:date])
+          d = Time.parse(mdata[:date])
           mdata[:y] = d.year
           mdata[:m] = d.month
           mdata[:d] = d.day
diff --git a/www/members/board-nominations.cgi 
b/www/members/board-nominations.cgi
index 79e4d8ee..c8c8ccdb 100755
--- a/www/members/board-nominations.cgi
+++ b/www/members/board-nominations.cgi
@@ -2,6 +2,7 @@
 PAGETITLE = "Board nominations cross-check" # Wvisible:meeting
 $LOAD_PATH.unshift '/srv/whimsy/lib'
 
+require 'time'
 require 'erb'
 require 'wunderbar/bootstrap'
 require 'whimsy/asf'
@@ -39,7 +40,7 @@ def setup_data
       next unless date.include? year
       next unless subject =~ /^\[?BOARD NOMI[MN]ATION\]?/i
       messageid = value[:MessageId]
-      emails << Email.new(subject, DateTime.parse(date), messageid, 
[value[:From]])
+      emails << Email.new(subject, Time.parse(date).utc, messageid, 
[value[:From]])
     end
   end
 
diff --git a/www/members/nominations.cgi b/www/members/nominations.cgi
index 0ad3a6c2..e85628ae 100755
--- a/www/members/nominations.cgi
+++ b/www/members/nominations.cgi
@@ -2,6 +2,7 @@
 PAGETITLE = "New Member nominations cross-check" # Wvisible:meeting
 $LOAD_PATH.unshift '/srv/whimsy/lib'
 
+require 'time'
 require 'erb'
 require 'wunderbar/bootstrap'
 require 'whimsy/asf'
@@ -41,7 +42,7 @@ def setup_data
       next if subject.downcase == 'member nomination process'
       next unless subject =~ /^\[?MEMBER(SHIP)? NOMI[MN]ATION\]?/i
       messageid = value[:MessageId]
-      emails << Email.new(subject, DateTime.parse(date), messageid, 
[value[:From]])
+      emails << Email.new(subject, Time.parse(date).utc, messageid, 
[value[:From]])
     end
   end
 
diff --git a/www/officers/coi.cgi b/www/officers/coi.cgi
index 847c99a7..6f0f7d37 100755
--- a/www/officers/coi.cgi
+++ b/www/officers/coi.cgi
@@ -5,13 +5,12 @@ require 'wunderbar'
 require 'wunderbar/bootstrap'
 require 'whimsy/asf'
 require 'mail'
-require 'date'
 require 'tmpdir'
 
 coi_url = ASF::SVN.svnurl('conflict-of-interest')
 COI_CURRENT_TEMPLATE_URL = File.join(coi_url, 'template.txt')
 
-YEAR = DateTime.now.strftime "%Y"
+YEAR = Time.now.strftime "%Y"
 COI_CURRENT_URL = File.join(coi_url, YEAR)
 
 user = ASF::Person.find($USER)
@@ -58,7 +57,7 @@ not_required_message = user_is_required ?' required':' not 
required'
 user_affirmation = SIGNERS.include? USERID
 have_affirmed_message = user_affirmation ? ' have affirmed' : ' have not 
affirmed'
 USER_IS_REQUIRED_BUT_NOT_AFFIRMED = (user_is_required and not user_affirmation)
-current_timestamp = DateTime.now.strftime "%Y-%m-%d %H:%M:%S %:z"
+current_timestamp = Time.now.strftime "%Y-%m-%d %H:%M:%S %:z"
 PANEL_MESSAGE = USER_IS_REQUIRED_BUT_NOT_AFFIRMED ?
   'Sign Your Conflict of Interest Affirmation':
   'Thank you for signing the Conflict of Interest Affirmation'
@@ -182,7 +181,7 @@ end
 # Emit a record of a user's submission - POST
 def emit_post(_)
   # The only information in the POST is $USER and $PASSWORD
-  current_timestamp = DateTime.now.strftime "%Y-%m-%d %H:%M:%S"
+  current_timestamp = Time.now.strftime "%Y-%m-%d %H:%M:%S"
 
   affirmed = get_affirmed_template(USERNAME, current_timestamp)
   user_filename = "#{USERID}.txt"
diff --git a/www/roster/views/actions/memstat.json.rb 
b/www/roster/views/actions/memstat.json.rb
index ca165658..b8f9489e 100644
--- a/www/roster/views/actions/memstat.json.rb
+++ b/www/roster/views/actions/memstat.json.rb
@@ -6,7 +6,7 @@ raise Exception.new("Unable to find member entry for 
#{@userid}") unless entry
 USERID = user.id
 USERMAIL = "#{USERID}@apache.org"
 USERNAME = user.cn
-TIMESTAMP = (DateTime.now.strftime "%Y-%m-%d %H:%M:%S %:z")
+TIMESTAMP = (Time.now.strftime "%Y-%m-%d %H:%M:%S %:z")
 
 # identify file to be updated
 members_txt = ASF::SVN.svnpath!('foundation', 'members.txt')

Reply via email to