Comments

Palmeus’s picture

Title: x days left until event » Showing the remaining days until event
Component: Date API » Date Timezone
karens’s picture

Status: Active » Fixed

Go to the Display Fields page. Change the formatter to use the 'Time Ago' option.

Status: Fixed » Closed (fixed)

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

stopshinal’s picture

How can I format it to show "x days" or display "0 days" if the date has already passed?

davvid’s picture

Hi, I have the same problem. I just want to display 'in ... days' (e.g. 'in 103 days') but it seems like there is no option to do that. Any ideas?

fdefeyter@gmail.com’s picture

Issue summary: View changes

same problem...

Jere Toivanen’s picture

Status: Closed (fixed) » Needs work
andriyun’s picture

Status: Needs work » Needs review
StatusFileSize
new9.41 KB

Status: Needs review » Needs work

The last submitted patch, 8: showing-remaining-days-until-event-date-1166036-8.patch, failed testing.

andriyun’s picture

Status: Needs work » Needs review
StatusFileSize
new11.55 KB
andypost’s picture

  1. +++ b/date.theme
    @@ -58,7 +58,6 @@
    -
    

    out of context

  2. +++ b/date.theme
    @@ -265,6 +279,9 @@ function theme_date_display_single($variables) {
    +  // Add remaining message
    ...
    +
       return $output;
     }
    

    return $output . $show_remaining_days;

  3. +++ b/date.theme
    @@ -326,10 +344,15 @@ function theme_date_display_range($variables) {
    +  // Add remaining message
    +  $output .= $show_remaining_days;
    +
    +  return $output;
    

    same

  4. +++ b/date.theme
    @@ -408,4 +431,18 @@ function theme_date_text_parts($variables) {
    +  $output = '';
    ...
    +  $output = '<div class="date-display-remaining"><span class="date-display-remaining">' . $show_remaining_text . '</span></div>';
    +  return $output;
    

    remove $output

  5. +++ b/date.field.inc
    @@ -19,7 +19,8 @@ function date_field_formatter_info() {
    -        'show_remaining_days' => false,
    +        'show_remaining_days' => FALSE,
    +
    

    extra line

andriyun’s picture

rerolled patch

podarok’s picture

Status: Needs review » Needs work

+ $summary[] = t('Show remainimg days: @value', array('@value' => ($settings['show_remaining_days'] ? 'yes' : 'no')));
should be remaining, not remainimg

andriyun’s picture

Fixed!
@andypost your notes considered and included!
Thank you very much for review!

andriyun’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 14: showing-remaining-days-until-event-date-1166036-14.patch, failed testing.

andypost’s picture

  1. +++ b/date.theme
    @@ -58,7 +58,6 @@
    -
    

    khm...

  2. +++ b/date.theme
    @@ -77,7 +76,7 @@ function theme_date_display_combination($variables) {
    -
    +  $show_remaining_days = $variables['show_remaining_days'];
    

    please leave "$output" separated by empty line

  3. +++ b/date.theme
    @@ -408,4 +426,18 @@ function theme_date_text_parts($variables) {
    +    $show_remaining_text = t('To event remaining') . ' ' . $remaining_days . ($remaining_days == 1 ? ' day' : ' days');
    

    use format_plural() here, "day[s]" should be translatable as part of the whole sentence

andriyun’s picture

Status: Needs work » Needs review
StatusFileSize
new6.64 KB

reroll and fix after review

andypost’s picture

  1. +++ b/date.theme
    @@ -153,6 +154,20 @@ function theme_date_display_combination($variables) {
    +    $remaining_days = floor((strtotime($variables['dates']['value']['formatted_iso']) -
    +    strtotime('now')) / (24 * 3600));
    

    nitpick, no idea how to format this code properly

  2. +++ b/date.theme
    @@ -153,6 +154,20 @@ function theme_date_display_combination($variables) {
    +    // Show remaining days only for future events
    

    needs dot.

  3. +++ b/date.theme
    @@ -445,4 +469,19 @@ function theme_date_form_element($variables) {
    +    $show_remaining_text = t('To event remaining') . ' ' . $remaining_days .
    +    format_plural($remaining_days, '1 day', '@count days');
    

    use this one liner:
    $show_remaining_text = format_plural($remaining_days, 'To event remaining 1 day', 'To event remaining @count days');

andriyun’s picture

Thanks!
Corrected!

Oooh.... I'm forget about fullstop!

andriyun’s picture

StatusFileSize
new6.63 KB
andypost’s picture

Status: Needs review » Reviewed & tested by the community

Needs commiter approval about markup

podarok’s picture

Status: Reviewed & tested by the community » Fixed

#21 commited
Thanks!

  • podarok committed 8745a35 on 7.x-2.x authored by andriyun
    Issue #1166036 by andriyun | Palmeus: Showing the remaining days until...

Status: Fixed » Closed (fixed)

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

niallmurphy-ie’s picture

Sorry to reopen but "The upcoming date less then 1 day" and "To event remaining 1 day" aren't grammatically correct. Something like the below would be better.

$show_remaining_text = t('Within a day'); // Or 'Today'
  if ($remaining_days) {
    $show_remaining_text = t('In') . ' ' . format_plural($remaining_days, '1 day', '@count days');
  }
madjr’s picture

#26 I agree.

Also a Big issue is that the DAYS only format / wording is NOT accurate.

It needs to SHOW Hours and Minutes too or a format like this: "Less than X day(s)".

Why? Because of these examples:

i.e.
Lets say event is in 7 days (1 week).
once we set our date to Start in 7 days, it will Output the following: "To event remaining 6 days" ....

What it needs to output should be something more accurate like:
-"To event remaining 6 days 23 hours and 59 seconds"
- or better yet: "The upcoming date less then 7 days" (for less than 24 hours it already outputs the following: "The upcoming date less then 1 day.")

Collins405’s picture

The actual wording here is incorrect.

No-one would say "To event remaining 6 days".

It should be "6 days remaining" or "6 days until the event".

EDIT: Just read #26, its early! I agree ;-)

Collins405’s picture

Line 480 of date.theme

Change...

$show_remaining_text = format_plural($remaining_days, 'To event remaining 1 day', 'To event remaining @count days');

to....

$show_remaining_text = format_plural($remaining_days, '1 day remaining', '@count days remaining');

nravens’s picture

Is there a way to change the text as in #26 and #29 without editing any files in the date module? Is string overrides the only option?

This worked in string overrides in case anyone else wants to go that route:
Original: To event remaining @count days
Replacement: what ever text you want @count days

niallmurphy-ie’s picture

Nakes, for trivial fixes like this, some jQuery is an easy option.

markdc’s picture

I agree with Collins405. These strings were clearly written by a non-native English speaker. Here's one I found that fails the spelling, grammar and brevity tests:

The upcoming date less then 1 day.

Suggested revision:

Tomorrow

I'm not a module developer but I am a native speaker with writing and proofreading experience. If I can be of any help, please don't hesitate to contact me. I'd love to give something back to the community however I can.

EDIT: Also just read #26. *facepalm*

joel_osc’s picture

Agree the wording is off... for those wanting to change them without code you can use the string overrides module on the following two string:

To event remaining 1 day

To event remaining @count days

colan’s picture

As this issue is closed/fixed, please open a new one to deal with the language problem (and relate it to this one). Thanks!