Dates in daylight saving time were still incorrect, fixed default tip
authorTimm S. Mueller <tmueller@schulze-mueller.de>
Fri, 12 Nov 2010 10:56:02 +0100
changeset 2f4034a59feaa
parent 1 522bf1c3dd7c
Dates in daylight saving time were still incorrect, fixed
bvv2cal
     1.1 --- a/bvv2cal	Fri Nov 12 09:23:02 2010 +0100
     1.2 +++ b/bvv2cal	Fri Nov 12 10:56:02 2010 +0100
     1.3 @@ -41,6 +41,11 @@
     1.4  	["ß"] = "ss"
     1.5  }
     1.6  
     1.7 +local function local2gmt(y, m, d, hour, min)
     1.8 +	return os.date("%s", os.time { day=d, month=m, year=y, hour=hour, min=min })
     1.9 +end
    1.10 +
    1.11 +
    1.12  local state = "waitcontent"
    1.13  local record, cell, result = { }, { }, { }
    1.14  local lnr = 1
    1.15 @@ -78,8 +83,8 @@
    1.16  					end
    1.17  					if sH then
    1.18  						-- convert dates to GMT
    1.19 -						local startdate = os.date("!%s", os.time { day=d, month=m, year=y, hour=sH, min=sM })
    1.20 -						local enddate = eH and os.date("!%s", os.time { day=d, month=m, year=y, hour=eH, min=eM })
    1.21 +						local startdate = local2gmt(y, m, d, sH, sM)
    1.22 +						local enddate = eH and local2gmt(y, m, d, eH, eM)
    1.23  						local what = table.concat(record, " "):match("^%s*(.-)%s*$")
    1.24  						what = what:gsub("([\128-\255].)", umlconv)
    1.25  						table.insert(result, { startdate, enddate, what })
    1.26 @@ -122,12 +127,12 @@
    1.27  for i = 1, #result do
    1.28  	local r = result[i]
    1.29  	print "BEGIN:VEVENT"
    1.30 -	local startdate = os.date("%Y%m%dT%H%M", r[1])
    1.31 +	local startdate = os.date("!%Y%m%dT%H%M", r[1])
    1.32  	print("UID:" .. startdate .. "." .. uid_uri)
    1.33  	print("SUMMARY:" .. r[3])
    1.34  	print("DTSTART:" .. startdate .. "00Z")
    1.35  	if r[2] then
    1.36 -		local enddate = r[2] and os.date("%Y%m%dT%H%M", r[2])
    1.37 +		local enddate = r[2] and os.date("!%Y%m%dT%H%M", r[2])
    1.38  		print("DTEND:" .. enddate .. "00Z")
    1.39  	end
    1.40  	print "END:VEVENT"