strptime on OS X always returns 0 for tm_wday and tm_yday

Bug #1414628 reported by Brian King
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Low
Aaron Wells
1.10
Fix Released
Low
Aaron Wells
1.9
Fix Released
Low
Unassigned
15.04
Fix Released
Low
Aaron Wells

Bug Description

As mentioned in this 5-year old comment on the php documentation page http://php.net/manual/en/function.strptime.php#89239 , tm_wday and tm_yday are not initialized on BSD-based systems.

This is apparently still true, at least on OS X. I'm running PHP 5.5.20, and these values are always set to 0.

htdocs/view/access.php in Mahara 1.10.2 uses tm_wday in the ptimetotime() function.

I propose that this method be updated to not use tm_wday, since it doesn't need to.

```
diff --git a/htdocs/view/access.php b/htdocs/view/access.php
index 26ea7d3..299bf89 100644
--- a/htdocs/view/access.php
+++ b/htdocs/view/access.php
@@ -336,8 +336,8 @@ function ptimetotime($ptime) {
         $ptime['tm_hour'],
         $ptime['tm_min'],
         $ptime['tm_sec'],
- 1,
- $ptime['tm_yday'] + 1,
+ $ptime['tm_mon'] + 1,
+ $ptime['tm_mday'],
         $ptime['tm_year'] + 1900
     );
 }
```

Tags: bsd osx
Aaron Wells (u-aaronw)
Changed in mahara:
importance: Undecided → Low
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/4274

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Hi Brian,

Thanks for the patch! I've pushed it into our code review system here: https://reviews.mahara.org/4274

As mentioned in the Mahara README file, we only officially support Debian & Ubuntu, but I'm always willing to consider community patches to increase our compatibility with our platforms. And it makes more sense to use the tm_mday parameter anyway.

Cheers,
Aaron

tags: added: bsd
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/4274
Committed: http://gitorious.org/mahara/mahara/commit/6e07fb0738fcf1da99e799b31961570b2743d37d
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit 6e07fb0738fcf1da99e799b31961570b2743d37d
Author: Brian King <email address hidden>
Date: Fri Feb 13 13:52:00 2015 +1300

Use different strptime params for BSD compatibility

Bug 1414628: The "tm_yday" (day of the year) param is not supplied by
strptime by default on BSD systems such as Mac OS X.
It works just as well to use "tm_mday" (day of the month) param instead,
and it also makes more sense!

Change-Id: I1484dcde4dbd8199f578a4eb5a58a9f78de45635

Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "1.10_STABLE" branch: https://reviews.mahara.org/4277

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/4277
Committed: http://gitorious.org/mahara/mahara/commit/a731e43527544a306085c4c0f394335cf029ef40
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.10_STABLE

commit a731e43527544a306085c4c0f394335cf029ef40
Author: Brian King <email address hidden>
Date: Fri Feb 13 13:52:00 2015 +1300

Use different strptime params for BSD compatibility

Bug 1414628: The "tm_yday" (day of the year) param is not supplied by
strptime by default on BSD systems such as Mac OS X.
It works just as well to use "tm_mday" (day of the month) param instead,
and it also makes more sense!

Change-Id: I1484dcde4dbd8199f578a4eb5a58a9f78de45635

Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "1.9_STABLE" branch: https://reviews.mahara.org/4678

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/4678
Committed: http://gitorious.org/mahara/mahara/commit/ec31ef4e699ad6cffa6fb3273b8e574fb9aaeead
Submitter: Aaron Wells (<email address hidden>)
Branch: 1.9_STABLE

commit ec31ef4e699ad6cffa6fb3273b8e574fb9aaeead
Author: Brian King <email address hidden>
Date: Fri Feb 13 13:52:00 2015 +1300

Use different strptime params for BSD compatibility

Bug 1414628: The "tm_yday" (day of the year) param is not supplied by
strptime by default on BSD systems such as Mac OS X.
It works just as well to use "tm_mday" (day of the month) param instead,
and it also makes more sense!

Change-Id: I1484dcde4dbd8199f578a4eb5a58a9f78de45635

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.