Days in Calendar Week

Hello there!

I’m new at this forum, and I fight with a big problem, so all I want is to give out all Dates in a Calendar Week for excample next week we have week 45 and I have 5 Textfields, and in the first field there should be 3. Nov 2014 in the second 4. Nov in the third 5. Nov and so on til friday.

I found nothing in the web about this and it’s really complicated, so I hope somebody has already done something like that and can help me!

Thanks and King regards

Here’s a way:

var
	ts:Vector.<TextField> = new <TextField>[t1, t2, t3, t4, t5],
	week:uint = 45
	
ts.forEach(function(t:*, i:int, v:Vector.<TextField>):void {
	t.text = new Date(new Date().fullYear, 0, 2 + i + (week - 1) * 7 - (new Date(new Date().fullYear, 0, 1)).getDay()).toLocaleDateString()
})

It assumes the instance names of your TextFields are t1, t2, etc.

Hi!

I can’t thank you enough this is so fu*kin’ easy but it’s exactly what I was looking for 5 weeks. Excuse my bad english, thanks a lot!!!

King regards

1 Like