Requirements:

Date API module for custom formats
Patch to common.inc for format_date to support "c" if using Drupal 6

1. Add new format:

<\s\p\a\n \c\l\a\s\s="\t\i\m\e\a\g\o" \t\i\t\l\e="c">F j, Y - G:i</\s\p\a\n>

2. Assign new format to Long date format

3. Enjoy Timeago enabled dates everywhere (Panels date formatters, Views date formatters, etc).

CommentFileSizeAuthor
#3 timeago-date-format-1409710.patch4.84 KBicecreamyou

Comments

icecreamyou’s picture

Status: Active » Postponed (maintainer needs more info)

Are you talking about custom date formats at admin/settings/date-time? I'm not sure where the Date module comes into play here.

I don't want to support any solutions that require patches to core, and also 'c' isn't supported until PHP5, so 'Y-m-d\TH:i:s+00:00' is the best we can do for D6. We can actually 1-up this for Drupal 7 by implementing hook_date_formats() to provide a new Timeago date format by default.

Where do you think this should be documented? Presumably in README.txt?

john.money’s picture

Well, hell's bells. You're right... Date API takes over the Date and Time add new format. On a clean install, the custom format works as expected. So Date API is not required.

And your suggestion to use:

Y-m-d\TH:i:s+00:00

instead of 'c' worked for me. I made the server timezone adjustment which I suppose will be hardcoded for every user anyways (no configurable timezones). Mine now looks like:

<\s\p\a\n \c\l\a\s\s="\t\i\m\e\a\g\o" \t\i\t\l\e="Y-m-d\TH:i:s-05:00">F j, Y - G:i</\s\p\a\n>

Doc in README would be swell. Thanks!

icecreamyou’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new4.84 KB

Ah, you're right, timezones will be inconsistent since that gets run through format_date() instead of gmdate(). I think Y-m-d\TH:i:sO should work instead of manually specifying the time zone (because if you hardcode it, the time will be wrong for everyone outside of your server's time zone).

Anyway, I've attached a patch for D7 that adds new date formats for Timeago. However, if you just manually add a Timeago format in D6 or D7, it won't work because the Timeago JS won't get added to the page. To get around that, the patch adds the Timeago JS on every page. I can't decide if this is acceptable or not. Possibly there should be an option.

icecreamyou’s picture

Title: Document using Timeago with Date and Time Custom Formats » Make Timeago a Date and Time format option

Renaming for clarity.

Reviews appreciated...

ezra-g’s picture

Status: Needs review » Needs work

This patch appears to be malformed:

git apply  timeago-date-format-1409710.patch 
fatal: corrupt patch at line 35
patch -p1 < timeago-date-format-1409710.patch 
patching file README.txt
patch: **** malformed patch at line 32:  
icecreamyou’s picture

Status: Needs work » Fixed

Committed fix to dev.

Requires clearing caches after upgrading before usage.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

fix link