<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.mechsploit.me/index.php?action=history&amp;feed=atom&amp;title=Module%3AAdd_to_Calendar</id>
	<title>Module:Add to Calendar - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.mechsploit.me/index.php?action=history&amp;feed=atom&amp;title=Module%3AAdd_to_Calendar"/>
	<link rel="alternate" type="text/html" href="https://wiki.mechsploit.me/index.php?title=Module:Add_to_Calendar&amp;action=history"/>
	<updated>2026-04-08T14:46:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.mechsploit.me/index.php?title=Module:Add_to_Calendar&amp;diff=190&amp;oldid=prev</id>
		<title>MechsploWikiSysop: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.mechsploit.me/index.php?title=Module:Add_to_Calendar&amp;diff=190&amp;oldid=prev"/>
		<updated>2025-09-02T02:50:11Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:50, 1 September 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>MechsploWikiSysop</name></author>
	</entry>
	<entry>
		<id>https://wiki.mechsploit.me/index.php?title=Module:Add_to_Calendar&amp;diff=189&amp;oldid=prev</id>
		<title>mw&gt;حبيشان: from metawiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.mechsploit.me/index.php?title=Module:Add_to_Calendar&amp;diff=189&amp;oldid=prev"/>
		<updated>2025-08-14T10:01:06Z</updated>

		<summary type="html">&lt;p&gt;from metawiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local function get_days_in_month (year, month)&lt;br /&gt;
	local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};&lt;br /&gt;
	&lt;br /&gt;
	year = tonumber (year);														-- force these to be numbers just in case&lt;br /&gt;
	month = tonumber (month);&lt;br /&gt;
&lt;br /&gt;
	if (2 == month) then														-- if February&lt;br /&gt;
		if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then		-- is year a leap year?&lt;br /&gt;
			return 29;															-- if leap year then 29 days in February&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return days_in_month [month];&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function get_date (date)&lt;br /&gt;
	local year, month, day, hour, minute, second;&lt;br /&gt;
&lt;br /&gt;
	year, month, day, hour, minute, second = date:match (&amp;#039;(%d%d%d%d)%-(%d%d?)%-(%d%d?)T(%d%d?):(%d%d?):(%d%d?)&amp;#039;);&lt;br /&gt;
	if not year then&lt;br /&gt;
		year, month, day, hour, minute, second = date:match (&amp;#039;^(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)$&amp;#039;);&lt;br /&gt;
		if not year then&lt;br /&gt;
			return nil;															-- test time did not match the specified patterns&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	local t = {[&amp;#039;year&amp;#039;] = tonumber(year), [&amp;#039;month&amp;#039;] = tonumber(month), [&amp;#039;day&amp;#039;] = tonumber(day), [&amp;#039;hour&amp;#039;] = tonumber(hour), [&amp;#039;min&amp;#039;] = tonumber(minute), [&amp;#039;sec&amp;#039;] = tonumber(second) or 0};&lt;br /&gt;
    &lt;br /&gt;
    if t.hour &amp;lt; 0 or t.hour &amp;gt; 23 or t.min &amp;lt; 0 or t.min &amp;gt; 59 or t.sec &amp;lt; 0 or t.sec &amp;gt; 59 then&lt;br /&gt;
        return nil; -- Invalid time values&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    if t.month &amp;lt; 1 or t.month &amp;gt; 12 then&lt;br /&gt;
        return nil; -- Invalid month&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    if t.day &amp;lt; 1 or t.day &amp;gt; get_days_in_month(t.year, t.month) then&lt;br /&gt;
        return nil; -- Invalid day for the month&lt;br /&gt;
    end&lt;br /&gt;
    return t; -- Return the table with valid date and time&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function get_utc_offset (utc_offset)&lt;br /&gt;
&lt;br /&gt;
	local h, m, sep, sign;&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	local patterns = {&lt;br /&gt;
		&amp;#039;^([%+%-±−]?)(%d%d?%.%d%d?)$&amp;#039;,										-- one or two fractional hour digits&lt;br /&gt;
		&amp;#039;^([%+%-±−]?)(%d%d?):(%d%d)$&amp;#039;,										-- two minute digits&lt;br /&gt;
		&amp;#039;^([%+%-±−]?)(%d%d?)[%.:]?$&amp;#039;,											-- hours only; ignore trailing separator&lt;br /&gt;
		}&lt;br /&gt;
	&lt;br /&gt;
	for _, pattern in ipairs(patterns) do										-- loop through the patterns&lt;br /&gt;
		sign, h, m = mw.ustring.match (utc_offset, pattern);&lt;br /&gt;
		if h then&lt;br /&gt;
			break;																-- if h is set then pattern matched&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not h then&lt;br /&gt;
		return nil;														-- did not match a pattern&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
    if &amp;#039;-&amp;#039; == sign then sign = -1; else sign = 1; end&lt;br /&gt;
	h = tonumber(h)&lt;br /&gt;
	m = tonumber(m) or 0;&lt;br /&gt;
	return sign * ((h * 3600) + (m * 60));&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function main(frame)&lt;br /&gt;
	local getArgs = require(&amp;#039;Module:Arguments with aliases&amp;#039;).getArgs&lt;br /&gt;
	local arg_aliases = {&lt;br /&gt;
        text = { &amp;#039;text&amp;#039;, &amp;#039;title&amp;#039; },&lt;br /&gt;
        date = { &amp;#039;date&amp;#039;, &amp;#039;start&amp;#039; },&lt;br /&gt;
        end_date = { &amp;#039;end_date&amp;#039;, &amp;#039;end&amp;#039; },&lt;br /&gt;
        details = { &amp;#039;details&amp;#039;, &amp;#039;description&amp;#039; },&lt;br /&gt;
        location = { &amp;#039;location&amp;#039;, &amp;#039;venue&amp;#039; },&lt;br /&gt;
        url_title = { &amp;#039;url_title&amp;#039; },&lt;br /&gt;
        timezone = { &amp;#039;timezone&amp;#039;, &amp;#039;tz&amp;#039; }&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    local args = getArgs(frame, {&lt;br /&gt;
        aliases = arg_aliases,&lt;br /&gt;
    })&lt;br /&gt;
    &lt;br /&gt;
    local date_txt = &amp;#039;&amp;#039;&lt;br /&gt;
	local tz_offest = (args.timezone and get_utc_offset(args.timezone)) or 0&lt;br /&gt;
	&lt;br /&gt;
    local date_t = args.date and get_date(args.date) or nil&lt;br /&gt;
    local end_date_t = args.end_date and get_date(args.end_date) or nil&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    if not date_t then&lt;br /&gt;
        return error(&amp;#039;Invalid date format. Please use YYYY-MM-DDThh:mm:ss or YYYYMMDDhhmmss.&amp;#039;);&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    local date_u = os.time(date_t) + tz_offest&lt;br /&gt;
    local end_date_u = date_u&lt;br /&gt;
&lt;br /&gt;
    if end_date_t then&lt;br /&gt;
        end_date_u = os.time(end_date_t) + tz_offest&lt;br /&gt;
        if end_date_u &amp;lt; date_u then&lt;br /&gt;
            return error(&amp;#039;End date cannot be before start date.&amp;#039;);&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    date_txt = os.date(&amp;#039;%Y%m%dT%H%M%SZ&amp;#039;, date_u) .. &amp;#039;/&amp;#039; .. os.date(&amp;#039;%Y%m%dT%H%M%SZ&amp;#039;, end_date_u);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    return &amp;#039;&amp;lt;span class=&amp;quot;add-to-calendar&amp;quot;&amp;gt;&amp;#039; ..&lt;br /&gt;
        &amp;#039;[https://calendar.google.com/calendar/render?action=TEMPLATE&amp;#039; .. &lt;br /&gt;
        &amp;#039;&amp;amp;text=&amp;#039; .. mw.uri.encode(args.text or &amp;#039;&amp;#039;) ..&lt;br /&gt;
        &amp;#039;&amp;amp;dates=&amp;#039; .. date_txt ..&lt;br /&gt;
        &amp;#039;&amp;amp;details=&amp;#039; .. mw.uri.encode(args.details or &amp;#039;&amp;#039;) ..&lt;br /&gt;
        &amp;#039;&amp;amp;location=&amp;#039; .. mw.uri.encode(args.location or &amp;#039;&amp;#039;) ..&lt;br /&gt;
        -- &amp;#039;&amp;amp;ctz=&amp;#039; .. mw.uri.encode(args.timezone or &amp;#039;UTC&amp;#039;) ..&lt;br /&gt;
        &amp;#039; &amp;#039; .. (args.url_title or &amp;#039;Add to calendar&amp;#039;) .. &amp;#039;]&amp;#039; ..&lt;br /&gt;
        &amp;#039;&amp;lt;/span&amp;gt;&amp;#039;;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return {&lt;br /&gt;
	main = main&lt;br /&gt;
}&lt;/div&gt;</summary>
		<author><name>mw&gt;حبيشان</name></author>
	</entry>
</feed>