"Supremacy2k" <Supremacy2k@gmail.com> wrote in message
news:42ee87bf$0$18636$14726298@news.sunsite.dk...
> Ville bare lige høre om det er muligt at finde dato'erne i en given uge.
>
> f.eks:
> Uge 31 (Denne Uge) består af: 1-7 August.
> Uge 32 består af 8-14 August.
> Uge 48 består af 28-30 November og 1-4 December.
>
> osv osv osv. ;)
>
har faktisk løst det med denne her:
<?php
echo $_REQUEST['week'] . "<br><br>\n";
?>
<?php
# Get a date by providing a week number, day of week and a year.
# Be careful! There are different definitions for weeks. Here the European
definition is used.
# In Europe a week starts on Monday.
# Also the start of the first week in a year is defined differently in
different countries.
# Here the ISO 8601 definition is used. This is the standard in Europe.
#
# I got the information from
http://home.t-online.de/home/PeterJHaas/delphi.htm
# There are many websites with information on week numbers.
# An excellent site on this subject is
http://www.pjh2.de/datetime/weeknumber/index.php
#
# This PHP source was based on the Delphi source code by Peter J. Haas
#
//give me the date of Friday week 20 of the year 2004 (Should result in
Friday May 14 2004)
$aWeek = $_REQUEST['week'];
$aYear = $_REQUEST['year'];
for ($i = 1; $i <= 7; $i++) {
$adate=datefromweeknr($aYear, $aWeek, $i);
echo 'The date (week='.$aWeek.' day='.$i.' year= '.$aYear.') is '.date('D
d-m-Y',$adate).'<br>';
}
function datefromweeknr($aYear, $aWeek, $aDay)
{
$FirstDayOfWeek=2; //First day of week is Monday
$BaseDate=4; //We calculate from 4/1 which is always in week 1
$CJDDelta=2415019; //Based on start of Chronological Julian Day
$StartDate = DelphiDate(mktime(1,0,0,01,$BaseDate,$aYear)); //The date to
start with
$Offset = ($aWeek-1) * 7 - mod(floor($StartDate) + $CJDDelta + 8 -
$FirstDayOfWeek,7) + $aDay - 1;
return PHPUnixTimeStamp($StartDate + $Offset);
}
#---------extra functions used----------
function DelphiDate($aPHPTime)
{
# The Unix Timestamp holds the number of seconds after January 1 1970
01:00:00
return div($aPHPTime,86400)+25569;
}
function PHPUnixTimeStamp($aDelphiDate)
{
# Delphi's TDate holds number of days after December 30 1899
return ($aDelphiDate-25569)*86400-3600;
}
function mod($number, $div)
{
return $number - floor($number/$div)*$div;
}
function div($number, $div)
{
return floor($number/$div);
}
?>
problemet er bare nu at den viser 1januar 2006 som uge 1, og 2-8 januar som
uge 1. :(
Ved ikke helt hvorfor, det er en del i kalenderen, og ikke i scriptet der
finder datoerne i ugenummeret.