私は学期の始まりの正確な日付を計算するために小さなクラスの組み合わせを構築しています。学期の始まりを決定するための規則は次のようになります:動的な日付の定義と条件
The monday of week number ## and after dd-mm-yyyy date
ie: for winter its week number 2 and it must be after the january 8th of that year
私はすべての学期(合計4)のために、これらのデータが含まれているリソースクラスを構築しています。しかし今、私はpublic holidays
に基づく問題に直面しています。それらのいくつかは月曜日にあるかもしれないので、その場合は火曜日の日付を取得する必要があります。
私は現在働いている問題は以下の通りです:
The target semester begins on or after august 30 and must be on week 35.
私はまた、9月の最初の月曜日に起こる祝日を考慮しなければなりません。 PHPの用語で
条件は、条件として「単語」これに最善の方法であることと、配列に格納しますどのような次
if (date('m', myDate) == 9 // if the month is september
&& date('w', myDate) == 1 // if the day of the week is monday
&& date('d', myDate) < 7 // if we are in the first 7 days of september
)
のですか?
EDIT
私は日付がここでの問題ではありません発見、十分に明らかにされていない可能性があります。実際の問題は、次のような設定配列で条件を記憶している。
$_ressources = array(
1 => array(
'dateMin' => '08-01-%',
'weekNumber' => 2,
'name' => 'Winter',
'conditions' => array()
),
2 => array(
'dateMin' => '30-04-%',
'weekNumber' => 18,
'name' => 'Spring',
'conditions' => array()
),
3 => array(
'dateMin' => '02-07-%',
'weekNumber' => 27,
'name' => 'Summer',
'conditions' => array()
),
4 => array(
'dateMin' => '30-08-%',
'weekNumber' => 35,
'name' => 'Autumn',
'conditions' => array("date('m', %date%) == 9 && date('w', %date%) == 1 && date('d', %date%) < 7")
)
);
私はそれが今提示の道を持っている問題は、私はどの私はむしろだろう、eval()
機能を使用する必要がありますということですではない。
私は質問へのあなたのアップデートに従って私の答えを更新しました。あなたの問題を解決しますか? – danishgoel