Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
742d0e37
Commit
742d0e37
authored
10 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Bad month return by function
parent
05fe8e45
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/core/lib/date.lib.php
+10
-8
10 additions, 8 deletions
htdocs/core/lib/date.lib.php
with
10 additions
and
8 deletions
htdocs/core/lib/date.lib.php
+
10
−
8
View file @
742d0e37
...
@@ -518,7 +518,7 @@ function dol_get_last_day($year,$month=12,$gm=false)
...
@@ -518,7 +518,7 @@ function dol_get_last_day($year,$month=12,$gm=false)
* @param int $day Day
* @param int $day Day
* @param int $month Month
* @param int $month Month
* @param int $year Year
* @param int $year Year
* @param int $gm False = Return date to compare with server TZ, True to compare with GM date.
* @param int $gm False
or 0 or 'server'
= Return date to compare with server TZ, True
or 1
to compare with GM date.
* @return array year,month,week,first_day,prev_year,prev_month,prev_day
* @return array year,month,week,first_day,prev_year,prev_month,prev_day
*/
*/
function
dol_get_first_day_week
(
$day
,
$month
,
$year
,
$gm
=
false
)
function
dol_get_first_day_week
(
$day
,
$month
,
$year
,
$gm
=
false
)
...
@@ -542,7 +542,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
...
@@ -542,7 +542,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
$tmpday
=
date
(
$tmparray
[
0
])
-
$seconds
;
$tmpday
=
date
(
$tmparray
[
0
])
-
$seconds
;
$tmpday
=
date
(
"d"
,
$tmpday
);
$tmpday
=
date
(
"d"
,
$tmpday
);
//Check first day of week is
form this month
or not
//Check first day of week is
in same month than current day
or not
if
(
$tmpday
>
$day
)
if
(
$tmpday
>
$day
)
{
{
$prev_month
=
$month
-
1
;
$prev_month
=
$month
-
1
;
...
@@ -559,6 +559,8 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
...
@@ -559,6 +559,8 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
$prev_month
=
$month
;
$prev_month
=
$month
;
$prev_year
=
$year
;
$prev_year
=
$year
;
}
}
$tmpmonth
=
$prev_month
;
$tmpyear
=
$prev_year
;
//Get first day of next week
//Get first day of next week
$tmptime
=
dol_mktime
(
12
,
0
,
0
,
$month
,
$tmpday
,
$year
,
1
,
0
);
$tmptime
=
dol_mktime
(
12
,
0
,
0
,
$month
,
$tmpday
,
$year
,
1
,
0
);
...
@@ -566,7 +568,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
...
@@ -566,7 +568,7 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
$tmparray
=
dol_getdate
(
$tmptime
,
true
);
$tmparray
=
dol_getdate
(
$tmptime
,
true
);
$prev_day
=
$tmparray
[
'mday'
];
$prev_day
=
$tmparray
[
'mday'
];
//Check
first
day of week is
form this month
or not
//Check
prev
day of week is
in same month than first day
or not
if
(
$prev_day
>
$tmpday
)
if
(
$prev_day
>
$tmpday
)
{
{
$prev_month
=
$month
-
1
;
$prev_month
=
$month
-
1
;
...
@@ -579,9 +581,9 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
...
@@ -579,9 +581,9 @@ function dol_get_first_day_week($day,$month,$year,$gm=false)
}
}
}
}
$week
=
date
(
"W"
,
dol_mktime
(
0
,
0
,
0
,
$month
,
$tmpday
,
$year
,
$gm
));
$week
=
date
(
"W"
,
dol_mktime
(
0
,
0
,
0
,
$
tmp
month
,
$tmpday
,
$
tmp
year
,
$gm
));
return
array
(
'year'
=>
$year
,
'month'
=>
$month
,
'week'
=>
$week
,
'first_day'
=>
$tmpday
,
'prev_year'
=>
$prev_year
,
'prev_month'
=>
$prev_month
,
'prev_day'
=>
$prev_day
);
return
array
(
'year'
=>
$year
,
'month'
=>
$month
,
'week'
=>
$week
,
'first_day'
=>
$tmpday
,
'first_month'
=>
$tmpmonth
,
'first_year'
=>
$tmpyear
,
'prev_year'
=>
$prev_year
,
'prev_month'
=>
$prev_month
,
'prev_day'
=>
$prev_day
);
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment