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

rubys 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 78e97e7  move tzlink logic closer to where time zone is set
78e97e7 is described below

commit 78e97e7d20922b64d4221fcd909643f55c9addae
Author: Sam Ruby <[email protected]>
AuthorDate: Mon Apr 20 08:24:16 2020 -0400

    move tzlink logic closer to where time zone is set
---
 lib/whimsy/asf/board.rb    | 21 +++++++++++++++++++++
 www/board/agenda/routes.rb | 15 +--------------
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/lib/whimsy/asf/board.rb b/lib/whimsy/asf/board.rb
index e1edb8f..766a50d 100644
--- a/lib/whimsy/asf/board.rb
+++ b/lib/whimsy/asf/board.rb
@@ -5,6 +5,27 @@ module ASF
   module Board
     TIMEZONE = ActiveSupport::TimeZone.new('UTC') rescue nil # HACK fix 
failure in public_committee_info.rb
 
+    # Convert a time to a timeanddate link, shortened if possible.
+    # Note: the path must be adjusted if the TIMEZONE changes.
+    def self.tzlink(time)
+      # build full time zone link
+      path = "/worldclock/fixedtime.html?iso=" +
+        time.strftime('%Y-%m-%dT%H:%M:%S') +
+        "&msg=ASF+Board+Meeting"
+      # path += '&p1=137' # time zone for PST/PDT locality
+      link = "http://www.timeanddate.com/#{path}";
+
+      # try to shorten time zone link
+      begin
+        shorten = 'http://www.timeanddate.com/createshort.html?url=' +
+          CGI.escape(path) + '&confirm=1'
+        shorten = URI.parse(shorten).read[/id=selectable>(.*?)</, 1]
+        link = shorten if shorten
+      end
+
+      link
+    end
+
     # sorted list of Directors
     # default to names only
     # if withId == true, then return hash: { id: {name: public_name}}
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index df1e2cb..c8fb6d5 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -514,6 +514,7 @@ get '/new' do
   # extract time and date for next meeting, month of previous meeting
   @meeting = ASF::Board.nextMeeting
   localtime = ASF::Board::TIMEZONE.utc_to_local(@meeting)
+  @tzlink = ASF::Board.tzlink(localtime)
   zone = ASF::Board::TIMEZONE.name
   @start_time = localtime.strftime('%H:%M') + ' ' + zone
   @adjournment = (localtime + 2.hours).strftime('%H:%M') + ' ' + zone
@@ -534,20 +535,6 @@ get '/new' do
   @pmcs = ASF::Board.reporting(@meeting)
   @owner = ASF::Board::ShepherdStream.new
 
-  # build full time zone link
-  path = "/worldclock/fixedtime.html?iso=" +
-    localtime.strftime('%Y-%m-%dT%H:%M:%S') +
-    "&msg=ASF+Board+Meeting"
-  @tzlink = "http://www.timeanddate.com/#{path}";
-
-  # try to shorten time zone link
-  begin
-    shorten = 'http://www.timeanddate.com/createshort.html?url=' +
-      CGI.escape(path) + '&confirm=1'
-    shorten = URI.parse(shorten).read[/id=selectable>(.*?)</, 1]
-    @tzlink = shorten if shorten
-  end
-
   # Get list of unpublished and unapproved minutes
   draft = YAML.load_file(Dir["#{AGENDA_WORK}/board_minutes*.yml"].sort.last)
   @minutes = dir("board_agenda_*.txt").

Reply via email to