Im trying to get the Monday and friday of the week that a date is in by adding a dateinterval to the date.
when these overlap a month/year change I expected it to sort out the months and years for me, but it doesn’t.
//the day of the week, with 1 = Sunday, 2 = Monday, 3 = Tuesday, 4 = Wednesday, 5 = Thursday, 6 = Friday, 7 = Saturday.
Dim day As Integer = Date.Now.DayOfWeek
minDate = Date.Now
maxdate = Date.Now
Dim Mdi As New DateInterval
Dim Fdi as new DateInterval
select case day
case 1
Mdi.days = 1
fdi.Days = 5
case 2
mdi.days = 0
fdi.Days = 4
case 3
mdi.days = -1
fdi.Days = 3
case 4
mdi.days = -2
fdi.Days = 2
case 5
mdi.days = -3
fdi.Days = 1
case 6
mdi.days = -4
fdi.Days = 0
case 7
mdi.days = -5
fdi.Days = -1
end select
Off the top of my head, something like this should get you started (not sure if it is proper XOJO date code for manipulating dates, but it should get you in the correct direction):
I was trying to use the dateinterval object in the new framework, to see how it works.
Is your code new framework or classic?[/quote]
Probably neither, I was attempting to show that there’s a short and simple way to calculate the dates without using the ‘Case’ statement.
[quote=197943:@Russ Lunn]@Norman Palardy unless i’m doing something really stupid (which has been known) this isn’t working right
adding 3 days to today should get me 03/07/2015 but i’m getting 03/06/2015[/quote]
I’m getting the same results. DateInterval doesn’t seem to be working correctly. It didn’t increment the month when the day rolled over.
I’m trying to get to grips with the new framework, mainly because Linux cgi won’t use locale specific date formatting, but also because it’s the future.
I’m using dateinterval and xojo.core.date as per the docs.
Norman says it works for him but I’m still having issues