VaioUserChris
February 2nd, 2006, 07:21 PM
Mike/Ron,
I think I found an error with one of the date functions. When you use the ":findndow" function to get the xth Monday of a month the date it returns is actually the xth Thursday. Likewise the xth Tuesday returns the xth Wednesday.
All other days are fine. Run the following script to see what I'm talking about...
est_date = "7.2.2006 00:00:00"
require 'date'
local d = date:parse( test_date )
print ("our test date =",d)
test_date2 = d:findndow (1,1)
print ("This is supposed to be the first Monday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,2)
print ("This is supposed to be the first Tuesday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,3)
print ("This is supposed to be the first Wednesday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,4)
print ("This is supposed to be the first Thursday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,5)
print ("This is supposed to be the first Friday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,6)
print ("This is supposed to be the first Saturday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,7)
print ("This is supposed to be the first Sunday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,1)
print ("This is supposed to be the second Monday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,2)
print ("This is supposed to be the second Tuesday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,3)
print ("This is supposed to be the second Wednesday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,4)
print ("This is supposed to be the second Thursday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,5)
print ("This is supposed to be the second Friday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,6)
print ("This is supposed to be the second Saturday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,7)
print ("This is supposed to be the second Sunday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
The second one is more of a question than an error. I noticed that in one of the provided date examples it starts with a date on 12/31 but after converting it using the date function it ends up with 7am on 1/1. But if you specify the hour:minute:second on 12/31 it converts the date to 12/31. Why does it change the date if you don't specify the time? (here's the example)
require 'date'
local test_date1 = "31-12-2000"
local test_date2 = "31-12-2000/00:00:00"
local converted_date1 = date:parse( test_date1 )
local converted_date2 = date:parse( test_date2 )
print ("test date one was:",test_date1," Converted date one is:",converted_date1)
print ("test date two was:",test_date2," Converted date two is:",converted_date2)Chris
I think I found an error with one of the date functions. When you use the ":findndow" function to get the xth Monday of a month the date it returns is actually the xth Thursday. Likewise the xth Tuesday returns the xth Wednesday.
All other days are fine. Run the following script to see what I'm talking about...
est_date = "7.2.2006 00:00:00"
require 'date'
local d = date:parse( test_date )
print ("our test date =",d)
test_date2 = d:findndow (1,1)
print ("This is supposed to be the first Monday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,2)
print ("This is supposed to be the first Tuesday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,3)
print ("This is supposed to be the first Wednesday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,4)
print ("This is supposed to be the first Thursday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,5)
print ("This is supposed to be the first Friday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,6)
print ("This is supposed to be the first Saturday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (1,7)
print ("This is supposed to be the first Sunday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,1)
print ("This is supposed to be the second Monday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,2)
print ("This is supposed to be the second Tuesday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,3)
print ("This is supposed to be the second Wednesday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,4)
print ("This is supposed to be the second Thursday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,5)
print ("This is supposed to be the second Friday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,6)
print ("This is supposed to be the second Saturday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
test_date2 = d:findndow (2,7)
print ("This is supposed to be the second Sunday of this month:",test_date2,"-- This day is actually a",test_date2.WeekDay)
The second one is more of a question than an error. I noticed that in one of the provided date examples it starts with a date on 12/31 but after converting it using the date function it ends up with 7am on 1/1. But if you specify the hour:minute:second on 12/31 it converts the date to 12/31. Why does it change the date if you don't specify the time? (here's the example)
require 'date'
local test_date1 = "31-12-2000"
local test_date2 = "31-12-2000/00:00:00"
local converted_date1 = date:parse( test_date1 )
local converted_date2 = date:parse( test_date2 )
print ("test date one was:",test_date1," Converted date one is:",converted_date1)
print ("test date two was:",test_date2," Converted date two is:",converted_date2)Chris