#!/usr/bin/env ruby # # Copyright (C) 2008 Harald Sitter # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License or (at your option) version 3 or any later version # accepted by the membership of KDE e.V. (or its successor approved # by the membership of KDE e.V.), which shall act as a proxy # defined in Section 14 of version 3 of the license. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . require 'fileutils' rversion = RUBY_VERSION.split(".") unless rversion[0].to_i >= 1 and rversion[1].to_i >= 9 puts("ERROR: please install ruby1.9, and start this script using ruby 1.9 ./migrateics.rb") exit 1 end timezone = IO.readlines("/etc/timezone")[0].chomp! unless $*[0] == nil file = $*[0] else file = ENV['HOME'] + "/.kde/share/apps/korganizer/std.ics" end puts("copy backup of #{file} to #{ENV['HOME']}") FileUtils.copy(file, ENV['HOME']) puts("opening #{file} for editing") file = File.new(file, File::RDWR) str = file.read() file.rewind() file.truncate( 0 ) nustr = [] for line in str.split("\n") if line.start_with?("DTSTART") or line.start_with?("DTEND") line = line.gsub!("Z","") end for replace in ["DTSTART","DTEND"] line.gsub!("#{replace}:","#{replace};TZID=#{timezone}:") end nustr += [line] end file << nustr.join("\n") file.close() puts("closing file object #{file}, finished editing")