🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.javascript
Article #39429

Re: Daty w JS

#39429
From: jerry
Date: Thu, 13 Apr 2006 20:26
36 lines
2049 bytes
> A nie prosciej czasem dodac zwyczajnie dni do dni,
> ustawic je w owej dacie, wiedzac, ze JS i tak
> np. z absurdalnego 33 kwietnia zrobi 3 maja?

Tak próbuję zrobić ale...

function test(StrDate)
	{

	var StrStartDate = new String("2005-04-10");
	var StartYear    = parseInt(StrStartDate.substr(0,4));
	var StartMonth   = parseInt(StrStartDate.substr(5,2));
	var StartDay     = parseInt(StrStartDate.substr(8,2));

	var StartDate = new Date(StartYear+1, StartMonth, StartDay);

	var StartDateYear  = StartDate.getYear();
	var StartDateMonth = StartDate.getMonth();
	var StartDateDay   = StartDate.getDate();
	 
alert(StartDate.getYear()+"-"+StartDate.getMonth()+"-"+StartDate.getDate());

		StartDate.setDate(StartDateDay+21);
	 
alert(StartDate.getYear()+"-"+StartDate.getMonth()+"-"+StartDate.getDate());

	}

ta funkcja dla daty, np: "2006-04-10" po dodaniu 21 dni wyświetli 
"2006-4-31"!!

Jak dodać te dni aby data nie przyjmowała idiotycznych wartości w stylu 
31 KWIETNIA, itp? - gdzie popełniam błąd?

Z góry dziękuję za pomoc.
Technical Details
Message-ID: <e1mbmj$bhr$1@news.interia.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!feed.news.interia.pl!not-for-mail
References: <e1lg25$8f1$1@news.interia.pl> <e1lhr2$2la$1@atena.e-wro.net> <e1m3a6$11da$1@news2.ipartners.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!feed.news.interia.pl!not-for-mail
From: jerry <j@xvc.pl>
Newsgroups: pl.comp.lang.javascript
Subject: Re: Daty w JS
Date: Thu, 13 Apr 2006 22:26:16 +0200
Organization: INTERIA.PL S.A.
Lines: 36
Message-ID: <e1mbmj$bhr$1@news.interia.pl>
References: <e1lg25$8f1$1@news.interia.pl> <e1lhr2$2la$1@atena.e-wro.net> <e1m3a6$11da$1@news2.ipartners.pl>
NNTP-Posting-Host: piatka-nat.os1.kn.pl
Mime-Version: 1.0
X-Trace: news.interia.pl 1144959507 11835 194.187.181.227 (13 Apr 2006 20:18:27 GMT)
X-Complaints-To: usenet@news.interia.pl
NNTP-Posting-Date: Thu, 13 Apr 2006 20:18:27 +0000 (UTC)
In-Reply-To: <e1m3a6$11da$1@news2.ipartners.pl>
X-Antivirus-Status: Clean
X-Antivirus: avast! (VPS 0615-2, 2006-04-12), Outbound message
User-Agent: Thunderbird 1.5 (Windows/20051201)
X-Authenticated-User: j.zarychta % interia+pl
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit