FANDOM


local p = {}
 
itis = "Fight it out."
 
D = {}
J = {} 
T = {}
 
function BirthdayInsert(Date, Japanese, Transliterated)
	table.insert(D, Date)
	table.insert(J, Japanese)
	table.insert(T, Transliterated)
end
 
BirthdayInsert('2001-01-01', '118', '217')
BirthdayInsert('2001-01-02', '119', '218')
BirthdayInsert('2001-01-03', '120', '219')
BirthdayInsert('2001-01-04', '121', '220')
BirthdayInsert('2001-01-05', '122', '221')
BirthdayInsert('2001-01-06', '123', '222')
BirthdayInsert('2001-01-07', '124', '223')
BirthdayInsert('2001-01-08', '125', '224')
BirthdayInsert('2001-01-09', '126', '225')
BirthdayInsert('2001-01-10', '127', '226')
BirthdayInsert('2001-01-11', '128', '227')
BirthdayInsert('2001-01-12', '129', '228')
BirthdayInsert('2001-01-13', '130', '229')
BirthdayInsert('2001-01-14', '131', '230')
BirthdayInsert('2001-01-15', '132', '231')
BirthdayInsert('2001-01-16', '133', '232')
BirthdayInsert('2001-01-17', '134', '233')
BirthdayInsert('2001-01-18', '135', '234')
BirthdayInsert('2001-01-19', '136', '235')
BirthdayInsert('2001-01-20', '137', '236')
BirthdayInsert('2001-01-21', '138', '237')
BirthdayInsert('2001-01-22', '139', '238')
BirthdayInsert('2001-01-23', '140', '239')
BirthdayInsert('2001-01-24', '141', '240')
BirthdayInsert('2001-01-25', '142', '241')
BirthdayInsert('2001-01-26', '143', '242')
BirthdayInsert('2001-01-27', '144', '243')
BirthdayInsert('2001-01-28', '145', '244')
BirthdayInsert('2001-01-29', '146', '245')
BirthdayInsert('2001-01-30', '147', '246')
BirthdayInsert('2001-01-31', '148', '247')
BirthdayInsert('2001-02-01', '149', '248')
BirthdayInsert('2001-02-02', '150', '249')
BirthdayInsert('2001-02-03', '151', '250')
BirthdayInsert('2001-02-04', '152', '251')
BirthdayInsert('2001-02-05', '153', '252')
BirthdayInsert('2001-02-06', '154', '253')
BirthdayInsert('2001-02-07', '155', '254')
BirthdayInsert('2001-02-08', '156', '255')
BirthdayInsert('2001-02-09', '157', '256')
BirthdayInsert('2001-02-10', '158', '257')
BirthdayInsert('2001-02-11', '159', '258')
BirthdayInsert('2001-02-12', '160', '259')
BirthdayInsert('2001-02-13', '161', '260')
BirthdayInsert('2001-02-14', '162', '261')
BirthdayInsert('2001-02-15', '163', '262')
BirthdayInsert('2001-02-16', '164', '263')
BirthdayInsert('2001-02-17', '165', '264')
BirthdayInsert('2001-02-18', '166', '265')
BirthdayInsert('2001-02-19', '167', '266')
BirthdayInsert('2001-02-20', '168', '267')
BirthdayInsert('2001-02-21', '169', '268')
BirthdayInsert('2001-02-22', '170', '269')
BirthdayInsert('2001-02-23', '171', '270')
BirthdayInsert('2001-02-24', '172', '271')
BirthdayInsert('2001-02-25', '173', '272')
BirthdayInsert('2001-02-26', '174', '273')
BirthdayInsert('2001-02-27', '175', '274')
BirthdayInsert('2001-02-28', '176', '275')
BirthdayInsert('2001-03-01', '177', '276')
BirthdayInsert('2001-03-02', '178', '277')
BirthdayInsert('2001-03-03', '179', '278')
BirthdayInsert('2001-03-04', '180', '279')
BirthdayInsert('2001-03-05', '181', '280')
BirthdayInsert('2001-03-06', '182', '281')
BirthdayInsert('2001-03-07', '183', '282')
BirthdayInsert('2001-03-08', '184', '283')
BirthdayInsert('2001-03-09', '185', '284')
BirthdayInsert('2001-03-10', '186', '285')
BirthdayInsert('2001-03-11', '187', '286')
BirthdayInsert('2001-03-12', '188', '287')
BirthdayInsert('2001-03-13', '189', '288')
BirthdayInsert('2001-03-14', '190', '289')
BirthdayInsert('2001-03-15', '191', '290')
BirthdayInsert('2001-03-16', '192', '291')
BirthdayInsert('2001-03-17', '193', '292')
BirthdayInsert('2001-03-18', '194', '293')
BirthdayInsert('2001-03-19', '195', '294')
BirthdayInsert('2001-03-20', '196', '295')
BirthdayInsert('2001-03-21', '197', '296')
BirthdayInsert('2001-03-22', '198', '297')
BirthdayInsert('2001-03-23', '199', '298')
BirthdayInsert('2001-03-24', '200', '299')
BirthdayInsert('2001-03-25', '201', '300')
BirthdayInsert('2001-03-26', '202', '301')
BirthdayInsert('2001-03-27', '203', '302')
BirthdayInsert('2001-03-28', '204', '303')
BirthdayInsert('2001-03-29', '205', '304')
BirthdayInsert('2001-03-30', '206', '305')
BirthdayInsert('2001-03-31', '207', '306')
BirthdayInsert('2001-04-01', '208', '307')
BirthdayInsert('2001-04-02', '209', '308')
BirthdayInsert('2001-04-03', '210', '309')
BirthdayInsert('2001-04-04', '211', '310')
BirthdayInsert('2001-04-05', '212', '311')
BirthdayInsert('2001-04-06', '213', '312')
BirthdayInsert('2001-04-07', '214', '313')
BirthdayInsert('2001-04-08', '215', '314')
BirthdayInsert('2001-04-09', '216', '315')
BirthdayInsert('2001-04-10', '217', '316')
BirthdayInsert('2001-04-11', '218', '317')
BirthdayInsert('2001-04-12', '219', '318')
BirthdayInsert('2001-04-13', '220', '319')
BirthdayInsert('2001-04-14', '221', '320')
BirthdayInsert('2001-04-15', '222', '321')
BirthdayInsert('2001-04-16', '223', '322')
BirthdayInsert('2001-04-17', '224', '323')
BirthdayInsert('2001-04-18', '225', '324')
BirthdayInsert('2001-04-19', '226', '325')
BirthdayInsert('2001-04-20', '227', '326')
BirthdayInsert('2001-04-21', '228', '327')
BirthdayInsert('2001-04-22', '229', '328')
BirthdayInsert('2001-04-23', '230', '329')
BirthdayInsert('2001-04-24', '231', '330')
BirthdayInsert('2001-04-25', '232', '331')
BirthdayInsert('2001-04-26', '233', '332')
BirthdayInsert('2001-04-27', '234', '333')
BirthdayInsert('2001-04-28', '235', '334')
BirthdayInsert('2001-04-29', '236', '335')
BirthdayInsert('2001-04-30', '237', '336')
BirthdayInsert('2001-05-01', '238', '337')
BirthdayInsert('2001-05-02', '239', '338')
BirthdayInsert('2001-05-03', '240', '339')
BirthdayInsert('2001-05-04', '241', '340')
BirthdayInsert('2001-05-05', '242', '341')
BirthdayInsert('2001-05-06', '243', '342')
BirthdayInsert('2001-05-07', '244', '343')
BirthdayInsert('2001-05-08', '245', '344')
BirthdayInsert('2001-05-09', '246', '345')
BirthdayInsert('2001-05-10', '247', '346')
BirthdayInsert('2001-05-11', '248', '347')
BirthdayInsert('2001-05-12', '249', '348')
BirthdayInsert('2001-05-13', '250', '349')
BirthdayInsert('2001-05-14', '251', '350')
BirthdayInsert('2001-05-15', '252', '351')
BirthdayInsert('2001-05-16', '253', '352')
BirthdayInsert('2001-05-17', '254', '353')
BirthdayInsert('2001-05-18', '255', '354')
BirthdayInsert('2001-05-19', '256', '355')
BirthdayInsert('2001-05-20', '257', '356')
BirthdayInsert('2001-05-21', '258', '357')
BirthdayInsert('2001-05-22', '259', '358')
BirthdayInsert('2001-05-23', '260', '359')
BirthdayInsert('2001-05-24', '261', '360')
BirthdayInsert('2001-05-25', '262', '361')
BirthdayInsert('2001-05-26', '263', '362')
BirthdayInsert('2001-05-27', '264', '363')
BirthdayInsert('2001-05-28', '265', '364')
BirthdayInsert('2001-05-29', '266', '365')
BirthdayInsert('2001-05-30', '267', '366')
BirthdayInsert('2001-05-31', '268', '367')
BirthdayInsert('2001-06-01', '269', '368')
BirthdayInsert('2001-06-02', '270', '369')
BirthdayInsert('2001-06-03', '271', '370')
BirthdayInsert('2001-06-04', '272', '371')
BirthdayInsert('2001-06-05', '273', '372')
BirthdayInsert('2001-06-06', '274', '373')
BirthdayInsert('2001-06-07', '275', '374')
BirthdayInsert('2001-06-08', '276', '375')
BirthdayInsert('2001-06-09', '277', '376')
BirthdayInsert('2001-06-10', '278', '377')
BirthdayInsert('2001-06-11', '279', '378')
BirthdayInsert('2001-06-12', '280', '379')
BirthdayInsert('2001-06-13', '281', '380')
BirthdayInsert('2001-06-14', '282', '381')
BirthdayInsert('2001-06-15', '283', '382')
BirthdayInsert('2001-06-16', '284', '383')
BirthdayInsert('2001-06-17', '285', '384')
BirthdayInsert('2001-06-18', '286', '385')
BirthdayInsert('2001-06-19', '287', '386')
BirthdayInsert('2001-06-20', '288', '387')
BirthdayInsert('2001-06-21', '289', '388')
BirthdayInsert('2001-06-22', '290', '389')
BirthdayInsert('2001-06-23', '291', '390')
BirthdayInsert('2001-06-24', '292', '391')
BirthdayInsert('2001-06-25', '293', '392')
BirthdayInsert('2001-06-26', '294', '393')
BirthdayInsert('2001-06-27', '295', '394')
BirthdayInsert('2001-06-28', '296', '395')
BirthdayInsert('2001-06-29', '297', '396')
BirthdayInsert('2001-06-30', '298', '397')
BirthdayInsert('2001-07-01', '299', '398')
BirthdayInsert('2001-07-02', '300', '399')
BirthdayInsert('2001-07-03', '301', '400')
BirthdayInsert('2001-07-04', '302', '401')
 
 
BirthdayInsert('1984-07-17', '木村麻美', 'Kimura Asami')
BirthdayInsert('2000-07-21', '田口夏実', 'Taguchi Natsumi')
BirthdayInsert('1980-07-22', '北上アミ', 'Kitagami Ami')
BirthdayInsert('1998-07-28', '岡村里星', 'Okamura Rise')
BirthdayInsert('1989-07-23', '鍾安琪', 'Zhong An Qi')
BirthdayInsert('1994-08-01', '和田彩花', 'Wada Ayaka')
BirthdayInsert('1998-08-05', '鈴木香音', 'Suzuki Kanon')
BirthdayInsert('1981-08-08', '飯田圭織', 'Iida Kaori')
BirthdayInsert('1981-08-10', '安倍なつみ', 'Abe Natsumi')
BirthdayInsert('1979-08-14', '三佳千夏', 'Miyoshi Chinatsu')
BirthdayInsert('1992-08-25', '夏焼雅', 'Natsuyaki Miyabi')
BirthdayInsert('1986-08-26', '川島幸', 'Kawashima Miyuki')
BirthdayInsert('2001-08-26', '斎藤夏奈', 'Saito Kana')
BirthdayInsert('1979-08-28', '前田有紀', 'Maeda Yuki')
BirthdayInsert('1992-08-28', '趙國蓉', 'Zhao Guo Rong')
BirthdayInsert('1998-08-28', '三瓶海南', 'Mikame Kana')
BirthdayInsert('1999-08-29', '真城佳奈', 'Mashiro Kana')
BirthdayInsert('2000-08-31', '井上ひかる', 'Inoue Hikaru')
BirthdayInsert('1990-09-05', '阿部麻美', 'Abe Asami')
BirthdayInsert('1983-09-06', 'ダニエル・デラウニー', 'Danielle Delaunay')
BirthdayInsert('1996-09-06', '木沢留那', 'Kizawa Runa')
 
BirthdayInsert('2000-09-06', '1', '100')
BirthdayInsert('2000-09-07', '2', '101')
BirthdayInsert('2000-09-08', '3', '102')
BirthdayInsert('2000-09-09', '4', '103')
BirthdayInsert('2000-09-10', '5', '104')
BirthdayInsert('2000-09-11', '6', '105')
BirthdayInsert('2000-09-12', '7', '106')
BirthdayInsert('2000-09-13', '8', '107')
BirthdayInsert('2000-09-14', '9', '108')
BirthdayInsert('2000-09-15', '10', '109')
BirthdayInsert('2000-09-16', '11', '110')
BirthdayInsert('2000-09-17', '12', '111')
BirthdayInsert('2000-09-18', '13', '112')
BirthdayInsert('2000-09-19', '14', '113')
BirthdayInsert('2000-09-20', '15', '114')
BirthdayInsert('2000-09-21', '16', '115')
BirthdayInsert('2000-09-22', '17', '116')
BirthdayInsert('2000-09-23', '18', '117')
BirthdayInsert('2000-09-24', '19', '118')
BirthdayInsert('2000-09-25', '20', '119')
BirthdayInsert('2000-09-26', '21', '120')
BirthdayInsert('2000-09-27', '22', '121')
BirthdayInsert('2000-09-28', '23', '122')
BirthdayInsert('2000-09-29', '24', '123')
BirthdayInsert('2000-09-30', '25', '124')
BirthdayInsert('2000-10-01', '26', '125')
BirthdayInsert('2000-10-02', '27', '126')
BirthdayInsert('2000-10-03', '28', '127')
BirthdayInsert('2000-10-04', '29', '128')
BirthdayInsert('2000-10-05', '30', '129')
BirthdayInsert('2000-10-06', '31', '130')
BirthdayInsert('2000-10-07', '32', '131')
BirthdayInsert('2000-10-08', '33', '132')
BirthdayInsert('2000-10-09', '34', '133')
BirthdayInsert('2000-10-10', '35', '134')
BirthdayInsert('2000-10-11', '36', '135')
BirthdayInsert('2000-10-12', '37', '136')
BirthdayInsert('2000-10-13', '38', '137')
BirthdayInsert('2000-10-14', '39', '138')
BirthdayInsert('2000-10-15', '40', '139')
BirthdayInsert('2000-10-16', '41', '140')
BirthdayInsert('2000-10-17', '42', '141')
BirthdayInsert('2000-10-18', '43', '142')
BirthdayInsert('2000-10-19', '44', '143')
BirthdayInsert('2000-10-20', '45', '144')
BirthdayInsert('2000-10-21', '46', '145')
BirthdayInsert('2000-10-22', '47', '146')
BirthdayInsert('2000-10-23', '48', '147')
BirthdayInsert('2000-10-24', '49', '148')
BirthdayInsert('2000-10-25', '50', '149')
BirthdayInsert('2000-10-26', '51', '150')
BirthdayInsert('2000-10-27', '52', '151')
BirthdayInsert('2000-10-28', '53', '152')
BirthdayInsert('2000-10-29', '54', '153')
BirthdayInsert('2000-10-30', '55', '154')
BirthdayInsert('2000-10-31', '56', '155')
BirthdayInsert('2000-11-01', '57', '156')
BirthdayInsert('2000-11-02', '58', '157')
BirthdayInsert('2000-11-03', '59', '158')
BirthdayInsert('2000-11-04', '60', '159')
BirthdayInsert('2000-11-05', '61', '160')
BirthdayInsert('2000-11-06', '62', '161')
BirthdayInsert('2000-11-07', '63', '162')
BirthdayInsert('2000-11-08', '64', '163')
BirthdayInsert('2000-11-09', '65', '164')
BirthdayInsert('2000-11-10', '66', '165')
BirthdayInsert('2000-11-11', '67', '166')
BirthdayInsert('2000-11-12', '68', '167')
BirthdayInsert('2000-11-13', '69', '168')
BirthdayInsert('2000-11-14', '70', '169')
BirthdayInsert('2000-11-15', '71', '170')
BirthdayInsert('2000-11-16', '72', '171')
BirthdayInsert('2000-11-17', '73', '172')
BirthdayInsert('2000-11-18', '74', '173')
BirthdayInsert('2000-11-19', '75', '174')
BirthdayInsert('2000-11-20', '76', '175')
BirthdayInsert('2000-11-21', '77', '176')
BirthdayInsert('2000-11-22', '78', '177')
BirthdayInsert('2000-11-23', '79', '178')
BirthdayInsert('2000-11-24', '80', '179')
BirthdayInsert('2000-11-25', '81', '180')
BirthdayInsert('2000-11-26', '82', '181')
BirthdayInsert('2000-11-27', '83', '182')
BirthdayInsert('2000-11-28', '84', '183')
BirthdayInsert('2000-11-29', '85', '184')
BirthdayInsert('2000-11-30', '86', '185')
BirthdayInsert('2000-12-01', '87', '186')
BirthdayInsert('2000-12-02', '88', '187')
BirthdayInsert('2000-12-03', '89', '188')
BirthdayInsert('2000-12-04', '90', '189')
BirthdayInsert('2000-12-05', '91', '190')
BirthdayInsert('2000-12-06', '92', '191')
BirthdayInsert('2000-12-07', '93', '192')
BirthdayInsert('2000-12-08', '94', '193')
BirthdayInsert('2000-12-09', '95', '194')
BirthdayInsert('2000-12-10', '96', '195')
BirthdayInsert('2000-12-11', '97', '196')
BirthdayInsert('2000-12-12', '98', '197')
BirthdayInsert('2000-12-13', '99', '198')
BirthdayInsert('2000-12-14', '100', '199')
BirthdayInsert('2000-12-15', '101', '200')
BirthdayInsert('2000-12-16', '102', '201')
BirthdayInsert('2000-12-17', '103', '202')
BirthdayInsert('2000-12-18', '104', '203')
BirthdayInsert('2000-12-19', '105', '204')
BirthdayInsert('2000-12-20', '106', '205')
BirthdayInsert('2000-12-21', '107', '206')
BirthdayInsert('2000-12-22', '108', '207')
BirthdayInsert('2000-12-23', '109', '208')
BirthdayInsert('2000-12-24', '110', '209')
BirthdayInsert('2000-12-25', '111', '210')
BirthdayInsert('2000-12-26', '112', '211')
BirthdayInsert('2000-12-27', '113', '212')
BirthdayInsert('2000-12-28', '114', '213')
BirthdayInsert('2000-12-29', '115', '214')
BirthdayInsert('2000-12-30', '116', '215')
BirthdayInsert('2000-12-31', '117', '216')
 
 
function Ordinal(anumber)
    if anumber % 10 == 1 then
        return anumber .. "st"
    elseif anumber % 10 == 2 then
        return anumber .. "nd"
    elseif anumber % 10 == 3 then
        return anumber .. "rd"
    else
        return anumber .. "th"
    end
end
 
function WhichBirthday(yyyymmdd)
    --Just rounds to which age is nearest. For standard uses of looking forward a week, it does the trick.
    _, _, y, m, d = string.find(yyyymmdd, "(%d%d%d%d)-(%d%d)-(%d%d)")
    difference = os.time() - os.time{year=y, month=m, day=d}
    difference = difference / 31555008
    difference = math.floor(difference+0.5) --Rounding
    return Ordinal(difference)
end
 
function BirthdayCut(mmdd)
    --Find first entry that's on/after the given month/day
    wantedday = hyphentodayofyear('2000-' .. mmdd)
    i = 0
    repeat
        i=i+1
        thisday = hyphentodayofyear2000(D[i])
    until thisday >= wantedday
 
   --We now want to move the first i entries in the three tables to the end to the end of those tables.
 
    for j=1, i, 1 do
        table.insert(D, D[1]) --Copy first value to new end entry...
        table.remove(D, 1) --Then remove the entry currently at first
        table.insert(J, J[1]) --Now do the same for J and T
        table.remove(J, 1)
        table.insert(T, T[1])
        table.remove(T, 1)
    end
end
 
function BirthdayCut2(mmdd)
    --Find first entry that's on/after the given month/day
    wantedday = hyphentodayofyear('2000-' .. mmdd)
    i = 0
    repeat
        i=i+1
        thisday = hyphentodayofyear2000(D[i])
    until thisday >= wantedday
 
   --We now want to move the first i entries in the three tables to temp tables.
 
    D2 = {}
    J2 = {}
    T2 = {}
 
    for j=1, i, 1 do
        table.insert(D2, D[1]) --Copy first value to new temp table...
        table.remove(D, 1) --Then remove the entry currently at first
        table.insert(J2, J[1]) --Now do the same for J and T
        table.remove(J, 1)
        table.insert(T2, T[1])
        table.remove(T, 1)
    end
 
    --Now move values from temp tables to end of original tables.
    for j=1, i, 1 do
        D[#D+1] = D2[j]
        J[#J+1] = J2[j]
        T[#T+1] = T2[j]
    end
end
 
function BirthdayCut3(mmdd)
    --Find first entry that's on/after the given month/day
    wantedday = hyphentodayofyear('2000-' .. mmdd)
    i = 0
    repeat
        i=i+1
        thisday = hyphentodayofyear2000(D[i])
    until thisday >= wantedday
 
   --We now want to move the first i entries in the three tables to temp tables.
 
    D2 = {}
    J2 = {}
    T2 = {}
 
    for j=1, i, 1 do
        table.insert(D2, D[j]) --Copy first value to new temp table...
        --table.remove(D, 1) --Then remove the entry currently at first
        table.insert(J2, J[j]) --Now do the same for J and T
        --table.remove(J, 1)
        table.insert(T2, T[j])
        --table.remove(T, 1)
    end
 
    --Now shift values from original table without use of remove.
    for j=i+1, #D, 1 do
        D[j-i] = D[j]
        J[j-i] = J[j]
        T[j-i] = T[j]
    end
 
    --Now move values from temp tables to end of original tables.
    for j=1, i, 1 do
        D[#D-i+j] = D2[j]
        J[#J-i+j] = J2[j]
        T[#T-i+j] = T2[j]
    end
end
 
function BirthdayCut4(mmdd)
    --Find first entry that's on/after the given month/day
    wantedday = hyphentodayofyear('2000-' .. mmdd)
    i = 0
    repeat
        i=i+1
        thisday = hyphentodayofyear2000(D[i])
    until thisday >= wantedday
 
   --We now want to copy the first i entries in the three tables to the table end.
 
    for j=1, i, 1 do
        table.insert(D, D[j]) --Copy first value to new temp table...
        --table.remove(D, 1) --Then remove the entry currently at first
        table.insert(J, J[j]) --Now do the same for J and T
        --table.remove(J, 1)
        table.insert(T, T[j])
        --table.remove(T, 1)
    end
 
end
 
function BirthdayCut3a(mmdd)
    --Find first entry that's on/after the given month/day
    --wantedday = hyphentodayofyear('2000-' .. mmdd)
    wantedday = mmdd
    i = 0
    repeat
        i=i+1
        --thisday = hyphentodayofyear2000(D[i])
        thisday = string.sub( D[i], 6, 10 )
        --mw.log(thisday)
    until thisday >= wantedday
 
   --We now want to move the first i entries in the three tables to temp tables.
 
    D2 = {}
    J2 = {}
    T2 = {}
 
    for j=1, i, 1 do
        table.insert(D2, D[j]) --Copy first value to new temp table...
        --table.remove(D, 1) --Then remove the entry currently at first
        table.insert(J2, J[j]) --Now do the same for J and T
        --table.remove(J, 1)
        table.insert(T2, T[j])
        --table.remove(T, 1)
    end
 
    --Now shift values from original table without use of remove.
    for j=i+1, #D, 1 do
        D[j-i] = D[j]
        J[j-i] = J[j]
        T[j-i] = T[j]
    end
 
    --Now move values from temp tables to end of original tables.
    for j=1, i, 1 do
        D[#D-i+j] = D2[j]
        J[#J-i+j] = J2[j]
        T[#T-i+j] = T2[j]
    end
end
 
function p.test()
	return "Hello, world!"
end
 
function p.test2()
        return "2014-02-28 " .. (os.time{year=2014, month=02, day=28}) .. " 2014-02-29 " .. (os.time{year=2014, month=02, day=29}) .. " 2014-03-01 " .. (os.time{year=2014, month=03, day=01})
end
 
function ostime (y,m,d)
     return os.time{year=y, month=m, day=d}
end
 
function ostimehyphen (yyyymmdd)
    _, _, y, m, d = string.find(yyyymmdd, "(%d%d%d%d)-(%d%d)-(%d%d)")
    return ostime(y,m,d)
end
 
function ostimehyphen2000 (yyyymmdd)
    _, _, y, m, d = string.find(yyyymmdd, "(%d%d%d%d)-(%d%d)-(%d%d)")
    return ostime(2000,m,d)
end
 
function ostimeNOWJST2000 ()
    return ostimehyphen2000(os.date("%Y-%m-%d",os.time()+32400))
end
 
function ostimeNEXJST2000(days)
    local num_days = days or 7
    return ostimehyphen2000(os.date("%Y-%m-%d",os.time()+32400+(num_days-1)*86400))
end
 
function hyphentodayofyear(yyyymmdd)
    return os.date("%j", ostimehyphen(yyyymmdd))
end
 
function hyphentodayofyear2000(yyyymmdd)
    _, _, y, m, d = string.find(yyyymmdd, "(%d%d%d%d)-(%d%d)-(%d%d)")
    return os.date("%j", ostimehyphen('2000-' .. m .. '-' .. d))
end
 
function WhereDayXStarts(mmdd)
    i = 0
    repeat
        i=i+1
    until string.sub( D[i], 6, 10 ) >= mmdd or i == table.getn(D)
    if string.sub(D[i], 6, 10) < mmdd then i = 1 end --If we've gone all the way and found squat, stick to the beginning.
    return i --.. " " .. string.sub( D[i], 6, 10 ) .. " >= " .. mmdd .. " or i == " .. table.getn(D)
end
 
function WhereDayXEnds(mmdd)
    _, _, m, d = string.find(mmdd, "(%d%d)-(%d%d)")
    if d+1 < 10 then
        nextday = m .. "-0" .. d+1 --Needs zero padded
    else
        nextday = m .. "-" .. d+1 --Even if this date isnt' real, it should work as a point of comparison
    end
    if nextday=="12-32" then
        return table.getn(D) -- As long as things are properly ordered, the table ends with the end of the year.
    else
        ThenWhereDayXEnds = "WhereDayXStarts(" .. nextday .. ")"
        itbegins = WhereDayXStarts(nextday)
        ThenWhereDayXEnds = itbegins - 1 --Just before where the next day starts, see.
        if ThenWhereDayXEnds == 0 then ThenWhereDayXEnds = table.getn(D) end --Again if the very beginning is "after", the end is... the end.
        return ThenWhereDayXEnds
    end
end
 
function p.test3()
        return "2014-02-28 " .. ostime(2014, 02, 28) .. " 2014-02-29 " .. ostime(2014, 02, 29) .. " 2014-03-01 " .. ostime(2014, 03, 01)
end
 
function TheScope ()
    itis = "THIS BIG"
end
 
function p.test4()
    Thing = "The scope is " .. itis
    TheScope()
    Thing = Thing ..  " The scope is " .. itis
    return Thing
end
 
function p.test5()
    return T[1] .. " " .. T[2]
end
 
function p.test6()
    return os.date("%c")
end
 
function p.test7()
        return "2014-02-28-0 " .. (os.time{year=2014, month=02, day=28, hour=0}) .. " 2014-02-28-9 " .. (os.time{year=2014, month=02, day=28, hour=9})
end
 
function p.test8()
    return "NOW: " .. os.time() .. " JST: " .. os.time()+32400
end
 
function p.test9()
    return "NOW: " .. os.date("%c") .. " JST: " .. os.date("%c", os.time()+32400)
end
 
function p.test10()
    return ":Easy\n:listening?"
end
 
 
function p.test11()
    return "<br>NOWJST2000: " .. os.date("%Y-%m-%d",os.time()+32400)
end
 
function p.test11a()
    return "<br>NOWJST2000a: " .. ostimehyphen(os.date("%Y-%m-%d",os.time()+32400))
end
 
function p.test11b()
    return "<br>NOWJST2000b: " .. ostimehyphen2000(os.date("%Y-%m-%d",os.time()+32400))
end
 
function p.test12()
    return "<br>Zukki: " .. ostimehyphen(D[2]) .. " " .. ostimehyphen2000(D[2])
end
 
function p.test13()
    return ostimehyphen('2014-08-05')
end
 
function p.test13a()
    return ostimehyphen2000('2014-08-05')
end
 
function p.test14()
    yyyymmdd = "1990-07-17"
    _, _, y, m, d = string.find(yyyymmdd, "(%d%d%d%d)-(%d%d)-(%d%d)")
    return "Y " .. y .. " M " .. m .. " D " .. d
end
 
function p.testx2()
    date = "17/7/1990"
    _, _, d, m, y = string.find(date, "(%d+)/(%d+)/(%d+)")
    return y .. " " .. m .. " " .. d
end
 
function p.test15()
    return "ostimeNOWJST2000: " .. ostimeNOWJST2000()
end
 
 
function p.test16()
    return "ostimeNEXJST2000: " .. ostimeNEXJST2000()
end
 
 
--BirthdayCut3a('08-05')
 
function p.upcoming(frame)
     --local num_days = frame.args.days or 7
     --local num_min = frame.args.min or 2
    local num_days = tonumber(frame.args.days or 7)
    local num_min = tonumber(frame.args.min or 2)
    local starting = frame.args.starting or os.date("%m-%d",os.time()+32400)
    --BirthdayCut3a(starting)
    --NOWJST2000 = ostimeNOWJST2000()
    NOWJST = starting
    --NEXJST2000 = ostimeNEXJST2000(num_days)
    --NEXJST = 
    output = os.clock() .. "\n" .. ""
    counter = 0
    first = 0
    lastdate = 0
    for i=1, table.getn(D), 1 do
        --output = output .. ":[[" .. T[i] .. "]] (" .. D[i] .. ")"
        if ostimehyphen2000(D[i]) >= NOWJST2000 and ostimehyphen2000(D[i]) <= NEXJST2000 then
            output = output .. " It's both."
            if ostimehyphen2000(D[i]) ~= lastdate then
                if ostimehyphen2000(D[i]) == NOWJST2000 then
                    output = output .. " HAPPY BIRTHDAY"
                else
                    output = output .. " COMING SOON"
                end
            end
            output = output .. ":[[" .. T[i] .. "]] (" .. D[i] .. ")\n"
            lastdate = ostimehyphen2000(D[i])
            counter = counter+1
            if first==0 then
                first = i
                if ostimehyphen2000(D[i+num_min-1]) > NEXJST2000 then NEXJST2000 = ostimehyphen2000(D[i+num_min-1]) end
                --Minimum goes to this date, so make that date the finish date.
            end
        end
    end
    output = output .. "There were " .. counter .. ". "
    output = output .. "I wanted " .. num_min .. ". "
    if counter >= num_min then
        output = output .. "That's enough."
    else
        output = output .. "That's not enough."
    end
    return output .. "<br>" .. os.clock()
 
end
 
function p.test17()
    return "NOW: " .. os.date("%c") .. " Different: " .. os.date("%j")
end
 
function p.test18()
    return "01-01: " .. hyphentodayofyear('2000-01-01') .. " 02-01: " .. hyphentodayofyear('2000-02-01') .. " 03-01: " .. hyphentodayofyear('2000-03-01') .. " 03-01: " .. hyphentodayofyear('2014-03-01') .. " 02-29: " .. hyphentodayofyear('2014-02-29')
end
 
function p.test18a()
    return "01-01: " .. hyphentodayofyear2000('2000-01-01') .. " 02-01: " .. hyphentodayofyear2000('2000-02-01') .. " 03-01: " .. hyphentodayofyear2000('2000-03-01') .. " 03-01: " .. hyphentodayofyear2000('2014-03-01') .. " 02-29: " .. hyphentodayofyear2000('2014-02-29')
end
 
function p.test19()
    return os.clock()
end
 
function p.test20()
    return BirthdayCut('08-05')
end
 
function p.test21()
    mmdd = "07-17"
    _, _, m, d = string.find(mmdd, "(%d%d)-(%d%d)")
    return "M " .. m .. " D " .. d
end
 
function p.test22()
        return "2013-12-31 " .. (os.time{year=2013, month=12, day=31}) .. " 2013-12-32 " .. (os.time{year=2013, month=12, day=32}) .. " 2014-01-01 " .. (os.time{year=2014, month=01, day=01})
end
 
function p.test23()
    return "Where 12-28 starts: " .. WhereDayXStarts('12-28') .. " " .. T[WhereDayXStarts('12-28')]
end
 
function p.test24()
    return "Where 01-02 ends: " .. WhereDayXEnds('01-02') .. " " .. T[WhereDayXEnds('01-02')]
end
 
function p.test25()
    mmdd='08-07'
    i = 0
    repeat
        i=i+1
    until string.sub( D[i], 6, 10 ) >= mmdd
    return string.sub( D[i], 6, 10 ) .. ">=" .. mmdd
end
 
function p.test26()
    starting = '08-07'
    part1 = string.sub(starting,1,2)
    part2 = string.sub(starting,4,5)
    num_days = 7
    return "P1: " .. part1 .. " P2: " .. part2 .. " End day: " .. os.date("%m-%d", os.time{year=2001, month=string.sub(starting,1,2), string.sub(starting,4,5)}+86400*num_days-1)
end
 
function p.test27()
    starting = '08-07'
    part1 = string.sub(starting,1,2)
    part2 = string.sub(starting,4,5)
    num_days = 7
    return os.date("%m-%d", os.time{year=2001, month=string.sub(starting,1,2), day=string.sub(starting,4,5)}+86400*num_days-1)
end
 
function p.test28()
    starting = '08-07'
    part1 = string.sub(starting,1,2)
    part2 = string.sub(starting,4,5)
    num_days = 7
    return os.date("%m-%d", os.time{year=2001, month=tonumber(string.sub(starting,1,2)), day=tonumber(string.sub(starting,4,5))}+86400*num_days-1)
end
 
function p.test29()
    mmdd = '01-02'
    _, _, m, d = string.find(mmdd, "(%d%d)-(%d%d)")
    nextday = m .. "-" .. d+1
    return nextday
end
 
 
function p.upcoming2(frame)
    num_days = tonumber(frame.args.days or 7)
    num_min = tonumber(frame.args.min or 2)
    starting = frame.args.starting or os.date("%m-%d",os.time()+32400)
    ending = os.date("%m-%d", os.time{year=2001, month=string.sub(starting,1,2), day=string.sub(starting,4,5)}+86400*num_days-1)
 
    STARTBEGINS = WhereDayXStarts(starting)
    ENDENDS = WhereDayXEnds(ending)
    LISTEND = table.getn(D)
 
    --output = "starting: " .. starting .. " ending: " .. ending .. " STARTBEGINS: " .. STARTBEGINS .. " ENDENDS: " .. ENDENDS .. " LISTEND: " .. LISTEND
 
    startread2 = 0
    endread2 = -1
    if ENDENDS>STARTBEGINS then
        if (ENDENDS-STARTBEGINS+1) >= num_min then
            --Is Y greater than X and Y-X>=Min? Fantastic! Read from spots X through Y.
            --output = output .. " CASE 1 "
            startread1 = STARTBEGINS
            endread1 = ENDENDS
            startread2 = 0
        elseif (LISTEND-STARTBEGINS+1) >= num_min then
            --Is Y greater than X, Y-X<Min, and End-X>=Min? OK, find what date X+Min is, find where that date ends, call it Y. Read from spots X through Y.
            --output = output .. " CASE 2 "
            ending = string.sub(D[STARTBEGINS+num_min-1], 6, 10 ) --mm-dd for minimum spot
            ENDENDS = WhereDayXEnds(ending)
            startread1 = STARTBEGINS
            endread1 = ENDENDS
        else
            --Need more to hit minimum, rest of list isn't enough. Need to check beginning of list for end of minimum and read those too.
            --output = output .. " CASE 3 "
            ending = string.sub(D[num_min-(LISTEND-STARTBEGINS+1)], 6, 10 ) --mm-dd for minimum spot
            ENDENDS = WhereDayXEnds(ending)
            startread1 = STARTBEGINS
            endread1 = LISTEND
            startread2 = 1
            endread2 = ENDENDS
        end
    else
        if (LISTEND-STARTBEGINS+ENDENDS) >= num_min then
            --Is Y less than X and (End-X+Y)>=Min? Read from spots X through End, then 1 through Y.
            --output = output .. " CASE 4 "
            startread1 = STARTBEGINS
            endread1 = LISTEND
            startread2 = 1
            endread2 = ENDENDS
        else
            --Is Y less than X, (End-X+Y)<Min? OK, find what date (Min-End-X) is, find where that date ends, call it Y. Read from spots X through End, then 1 through Y.
            --Very similar to an earlier case, except this time Y has already looped. Calculations should remain the same, though.
            --output = output .. " CASE 5 "
            ending = string.sub(D[num_min-(LISTEND-STARTBEGINS+1)], 6, 10 ) --mm-dd for minimum spot
            ENDENDS = WhereDayXEnds(ending)
            startread1 = STARTBEGINS
            endread1 = LISTEND
            startread2 = 1
            endread2 = ENDENDS
        end
    end
 
    --output = output .. " ending: " .. ending .. " ENDENDS: " .. ENDENDS
    --output = output.. " startread1: " .. startread1 .. " " .. T[startread1] .. " endread1: " .. endread1 .. " " .. T[endread1] .. " startread2: " .. startread2 .. " endread2: " .. endread2 .. "\n"
 
    lastday = 0
    output = ""
 
    --First read group
    i = startread1
    while i<= endread1 do
        thisday = string.sub( D[i], 6, 10 )
        if thisday ~= lastday then --It's a new day, something should be written.
            output = output .. ";" .. os.date("%B %e", os.time{year=2001, month=string.sub(D[i],6,7), day=string.sub(D[i],9,10)}) .. ", "
            if thisday==starting then output = output .. "Happy Birthday!" else output = output .. "Coming Soon" end
            output = output .. "\n"
        end
        output = output .. ":[[" .. T[i] .. "]] (" .. WhichBirthday(D[i]) .. ")\n"
        lastday = thisday
        i=i+1
    end
 
    --Second read group
    i = startread2
    while i<= endread2 do
        thisday = string.sub( D[i], 6, 10 )
        if thisday ~= lastday then --It's a new day, something should be written.
            output = output .. ";" .. os.date("%B %e", os.time{year=2001, month=string.sub(D[i],6,7), day=string.sub(D[i],9,10)}) .. ", "
            if thisday==starting then output = output .. "Happy Birthday!" else output = output .. "Coming Soon" end
            output = output .. "\n"
        end
        output = output .. ":[[" .. T[i] .. "]] (" .. WhichBirthday(D[i]) .. ")\n"
        lastday = thisday
        i=i+1
    end
 
 
    return output -- .. " " .. os.clock()
end
 
function p.test30(frame)
    mmdd = frame.args.mmdd
    return WhereDayXEnds(mmdd)
end
 
function p.test31(frame)
    mmdd = frame.args.mmdd
    return WhereDayXStarts(mmdd)
end
 
function p.test32(frame)
    anumber = frame.args.anumber
    return Ordinal(anumber)
end
 
function p.test33(frame)
    yyyymmdd = frame.args.yyyymmdd
    return WhichBirthday(yyyymmdd)
end
 
function p.test34(frame)
    i = tonumber(frame.args.i)
    --return ":[[" .. T[i] .. "]] (" .. WhichBirthday(D[i]) .. ")\n"
    return ":[[" .. T[i] .. "]] (" .. D[i] .. ")\n"
end
 
function p.test35(frame)
    i = tonumber(frame.args.i)
    return D[i] .. " " .. T[i] .. " " .. J[i]
end
 
function p.year(frame)
    year = frame.args[1] or 1982
    lastday = 0
    output = ""
    for i=1, table.getn(D), 1 do
        if string.sub(D[i],1,4) == year then
            thisday = string.sub( D[i], 6, 10 )
            if thisday ~= lastday then
                output = output .. ";" .. os.date("%B %e", os.time{year=2001, month=string.sub(D[i],6,7), day=string.sub(D[i],9,10)}) .. "\n"
            end
            output = output .. ":[[" .. T[i] .. "]]\n"
            lastday = thisday
        end
    end
    return output
end
 
function p.month(frame)
    month = frame.args[1] or 1
    if month == '1' or month == '01' then
        starting='01-01'
        ending='01-31'
    elseif month == '2' or month == '02' then
        starting='02-01'
        ending='02-29'
    elseif month == '3' or month == '03' then
        starting='03-01'
        ending='03-31'
    elseif month == '4' or month == '04' then
        starting='04-01'
        ending='04-30'
    elseif month == '5' or month == '05' then
        starting='05-01'
        ending='05-31'
    elseif month == '6' or month == '06' then
        starting='06-01'
        ending='06-30'
    elseif month == '7' or month == '07' then
        starting='07-01'
        ending='07-31'
    elseif month == '8' or month == '08' then
        starting='08-01'
        ending='08-31'
    elseif month == '9' or month == '09' then
        starting='09-01'
        ending='09-30'
    elseif month == '10' then
        starting='10-01'
        ending='10-31'
    elseif month == '11' then
        starting='11-01'
        ending='11-30'
    elseif month == '12' then
        starting='12-01'
        ending='12-31'
    end
 
    STARTBEGINS = WhereDayXStarts(starting)
    ENDENDS = WhereDayXEnds(ending)
 
    lastday = 0
    output = ""
 
    i = STARTBEGINS
    while i<= ENDENDS do
        thisday = string.sub( D[i], 6, 10 )
        if thisday ~= lastday then --It's a new day, something should be written.
            output = output .. ";" .. os.date("%B %e", os.time{year=2001, month=string.sub(D[i],6,7), day=string.sub(D[i],9,10)}) .. "\n"
        end
        output = output .. ":[[" .. T[i] .. "]] (" .. string.sub(D[i], 1, 4) .. ")\n"
        lastday = thisday
        i=i+1
    end
    return output
end
 
function p.age(frame)
    age = frame.args[1] or 20
    output = ""
    starting = os.date("%Y-%m-%d",os.time()+32400) --Y-m-d for today in Japan
    _, _, y, m, d = string.find(starting, "(%d%d%d%d)-(%d%d)-(%d%d)")
    LOWBORDER = y-age .. "-" .. m .. "-" .. d
    if d+1<10 then --needs a leading 0
        HIGHBORDER = y-age-1 .. "-" .. m .. "-0" .. d+1
    else
        HIGHBORDER = y-age-1 .. "-" .. m .. "-" .. d+1 --Might be an improper date, but for comparison purposes should work
    end
    --output = "LOWBORDER: " .. LOWBORDER .. " HIGHBORDER: " .. HIGHBORDER
    --return output
    STARTBEGINS = WhereDayXStarts(string.sub(HIGHBORDER,6,10))
 
    --First half
    i = STARTBEGINS
    while i<= table.getn(D) do
        if D[i] >= HIGHBORDER and D[i] <= LOWBORDER then
            output = output .. ":[[" .. T[i] .. "]] (" .. D[i] .. ")\n"
        end
        i=i+1
    end
 
    --Second half
    i = 1
    while i<= STARTBEGINS-1 do
        if D[i] >= HIGHBORDER and D[i] <= LOWBORDER then
            output = output .. ":[[" .. T[i] .. "]] (" .. D[i] .. ")\n"
        end
        i=i+1
    end
 
    return output
end
 
return p