CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Displaying week day names in date
Pages: [1]

Author Topic: Displaying week day names in date  (Read 4641 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Displaying week day names in date
October 19, 2009, 09:42:09 am
Hi there,

My client wants to display weekday names in CiviCRM for events (good idea when you think about it).

I changed the long date format setting here:
http://drupal.demo.civicrm.org/civicrm/admin/setting/date?reset=1

to "%A %B %E%f, %Y %l:%M %P"

following the POSIX standard I found at:
http://www.opengroup.org/onlinepubs/009695399/functions/strftime.html

But it came up with a capital AM (which is what you would expect if you were using PHP date).

I see this bug: http://issues.civicrm.org/jira/browse/CRM-4893 and this related forum post.

Have you made a choice about what you want to settle on?  If so, you think this bug is simple enough for me to fix?

Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Displaying week day names in date
October 20, 2009, 04:35:07 am
Quote from: michaelmcandrew on October 19, 2009, 09:42:09 am
I changed the long date format setting here:
http://drupal.demo.civicrm.org/civicrm/admin/setting/date?reset=1

to "%A %B %E%f, %Y %l:%M %P"

following the POSIX standard I found at:
http://www.opengroup.org/onlinepubs/009695399/functions/strftime.html

But it came up with a capital AM (which is what you would expect if you were using PHP date).

Yes, it seems we don’t handle %a/%A in CiviCRM.

Quote
I see this bug: http://issues.civicrm.org/jira/browse/CRM-4893 and this related forum post.

Have you made a choice about what you want to settle on?

We’re switching the calendar widget in CiviCRM 3.1, so we’ll make a call based on the new calendar choice.

Quote
If so, you think this bug is simple enough for me to fix?

You can try tweaking the CRM_Utils_Date::customFormat() function so that it maps %A to the appropriate weekday (the mapping is provided by the CRM_Utils_Date::getFullWeekdayNames() method, so you need to extract the weekday from the date and map %A to the weekday-number → weekday-name in the $date array near the end of the function).
« Last Edit: October 20, 2009, 04:39:39 am by Piotr Szotkowski »
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

jamie

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 6
Re: Displaying week day names in date
December 29, 2009, 11:32:26 am
This is a more hacky way of getting it to work (I'm not sure how to elegantly use the getFullWeekdayNames()). With the attached diff I simply use the PHP date function to get the day of the week.

Piotr Szotkowski

  • I live on this forum
  • *****
  • Posts: 1497
  • Karma: 57
Re: Displaying week day names in date
January 11, 2010, 03:53:30 am
Hm, it seems we map %A to AM/PM (right above where you patched the file), so I’d rather not break the existing behaviour in a stable release. I’ll see what we do for the calendar stuff in v3.1.
« Last Edit: January 11, 2010, 03:58:09 am by Piotr Szotkowski »
If you found the above helpful, please consider helping us in return – you can even steer CiviCRM’s future and help us extend CiviCRM in ways useful to you.

gsaha

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: drupal
  • MySQL version: 1.2
  • PHP version: 4
Re: Displaying week day names in date
September 28, 2012, 05:24:02 am
Quote from: Piotr Szotkowski on January 11, 2010, 03:53:30 am
Hm, it seems we map %A to AM/PM (right above where you patched the file), so I’d rather not break the existing behaviour in a stable release. I’ll see what we do for the calendar stuff in v3.1.

Hi Jamie,
I am on version 3.3 and need to display the weekday of the event.
I tried to follow your diff file, but because of my inexperience having problem editing the date.php file correctly.
Attached is my date.php file. Could you help me edit it based on your diff file so I can display weekday of the event?
Thanks so much

jamie

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 6
Re: Displaying week day names in date
September 28, 2012, 06:41:58 am
On that version Date.php, line 378 should be changed to:

'%A' => date('l',strtotime($dateString)),

And then you can use %A to stand for the day of the week.

However, Piotr is right - it's not a great solution because anyone who is using %A now and expecting to get AM/PM will be surprised.

As far as I can tell, CiviCRM is still using a mixture of POSIX standards and PHP standards (PHP says %A should be AM/PM while POSIX says it should be the day of the week). 

CRM-4893 was originally opened to solve that problem, but the scope seems to have changed. Now this issue has been opened: http://issues.civicrm.org/jira/browse/CRM-10367 which directly addresses the problem (but is still unresolved).

jamie

gsaha

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: drupal
  • MySQL version: 1.2
  • PHP version: 4
Re: Displaying week day names in date
September 28, 2012, 01:23:04 pm
Jamie..thanks so much.
That worked!
Cheers

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Displaying week day names in date

This forum was archived on 2017-11-26.