removed slot operator (no longer needed) & class proto bug fix to use NewSlot by...
[vox.git] / _examples / dow.vx
blob4ffdf6bb05786748d4d989cd9dfd956e5617a266
2 function datetoday(day, month, year)
4     local z, dayofweek
5     if (month < 3) z = y-1
6     else z = year
7     dayofweek = (23 * month / 9 + day + 4 + year + z / 4 - z / 100 + z / 400)
8     if(month >= 3) dayofweek -= 2
9     dayofweek = dayofweek % 7
10     return dayofweek
13 local values, day, month, year, dow, months, days
14 months = [
15     "january", "february", "march",
16     "april", "may", "june", "july",
17     "august", "september", "october",
18     "november", "december"]
20 days = [
21     "Monday", "Tuesday", "Wednesday", "Thursday",
22     "Friday", "Saturday", "Sunday"]
25 print("Enter the date as 'dd mm yyyy' (without quotes): ")
26 values = io.stdin.readline().split(" ")
27 day = values[0].tointeger()
28 month = values[1].tointeger()
29 year = values[2].tointeger()
30 dow = days[datetoday(day, month, year) - 1]
31 println("The %d' of %s, %d is a %s".fmt(day, months[month-1], year, dow))