Development

#3322 ([PATCH] DateHelper distance_of_time_in_words() generates incorrect output for some dates)

You must first sign up to be able to contribute.

Ticket #3322 (closed defect: wontfix)

Opened 2 years ago

Last modified 1 year ago

[PATCH] DateHelper distance_of_time_in_words() generates incorrect output for some dates

Reported by: paulom Assigned to: fabien
Priority: minor Milestone:
Component: helpers Version: 1.0.17
Keywords: Cc:
Qualification: Unreviewed

Description

The function distance_of_time_in_words() in the DateHelper? generates wrong text for some values over 2 years. Example, 'over 3 years' string is generated for a date such as 1000 days (2,73 years). The problem is in:

    $string = 'over %years% years';
    $parameters['%years%'] = round($distance_in_minutes / 525960);

floor() should be used instead of round().

Attachments

DateHelper-patch.diff (405 bytes) - added by paulom on 04/12/08 05:29:46.
DateHelper-patch2.diff (0.7 kB) - added by paulom on 08/24/08 10:12:31.

Change History

04/12/08 05:29:46 changed by paulom

  • attachment DateHelper-patch.diff added.

05/04/08 09:25:19 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone set to 1.0.14.

in r8763 and r8764

08/24/08 10:12:11 changed by paulom

  • status changed from closed to reopened.
  • version changed from 1.0.12 to 1.0.17.
  • resolution deleted.
  • milestone deleted.

Reopening this ticket: still something to tweak.

With the change made on this ticket, a date close to two years now says 'about 1 year'. For 2 or more years, the rule works fine saying 'above X years', but the exception for 1 year is not longer working.

I suggest the exception for 1 year to be removed and anything above 12 months would says 'above X year(s)', skipping the 'about 1 year' exception. Check patch attached.

08/24/08 10:12:31 changed by paulom

  • attachment DateHelper-patch2.diff added.

08/24/08 10:44:32 changed by FabianLange

  • status changed from reopened to closed.
  • resolution set to wontfix.

If you want to have an output a your patch would create, you can easily use I18n for that. No need to patch away a case that other people would like to have

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.