recurr icon indicating copy to clipboard operation
recurr copied to clipboard

Added start date in TextTransformer

Open libertjeremy opened this issue 5 years ago • 3 comments

Hi,

For more verbosity on the Rule, I added the start date to the translations for TextTransformer.

Please check the translations (except french haha).

If everything is ok, I will add the associated tests.

libertjeremy avatar Feb 15 '19 13:02 libertjeremy

I'm hesitant on this one because it makes many of the strings read awkwardly and maybe a bit too verbose. e.g. In my personal usages of Recurr, I like that it just describes the recurrence rule and doesn't include the start date.

I think that if one wants to include the start date, it would be better to manually prepend something like "Starting on %date%, ". I'm open to other opinions though.

Test suite:

yearly on March 16 from March 16, 2014 once
yearly on March 16 from March 16, 2014 for 3 times
yearly on March 16 from March 16, 2014 until July 4, 2014
yearly on March 16 from March 16, 2014 (~ approximate)
yearly on March 16 from March 16, 2014 (~ approximate)
yearly on March 16 from March 16, 2014 (~ approximate)
monthly from March 16, 2014 (~ approximate)
monthly from March 16, 2014 (~ approximate)
monthly from March 16, 2014
every 10 months from March 16, 2014
every January, May and August from March 16, 2014
every 2 months in January, May and August from March 16, 2014
monthly on the 1st, 5th and 21st from March 16, 2014
monthly on Tuesday or Friday the 1st, 5th or 21st from March 16, 2014
monthly on the 21st day and on the last day from March 16, 2014
monthly on Tuesday or Friday the 1st day or 2nd to the last day from March 16, 2014
monthly on Tuesday, Wednesday and Friday from March 16, 2014
monthly on the 4th Monday from March 16, 2014
monthly on the 4th Monday and 2nd Tuesday from March 16, 2014
monthly on the 4th Monday, 2nd Tuesday and 3rd Wednesday from March 16, 2014
monthly on the 1st Monday, 1st Tuesday, 2nd Wednesday, 3rd Wednesday, 4th Wednesday, last Thursday, 2nd to the last Friday, 3rd to the last Saturday and 4th to the last Sunday from March 16, 2014
daily from March 16, 2014
every 10 days from March 16, 2014
daily in January, May and August from March 16, 2014
every 2 days in January, May and August from March 16, 2014
daily on the 1st, 5th and 21st of the month from March 16, 2014
daily on Tuesday or Friday the 1st, 5th or 21st of the month from March 16, 2014
daily on Tuesday, Wednesday and Friday from March 16, 2014
yearly on March 16 from March 16, 2014
every 10 years on March 16 from March 16, 2014
every January, May and August from March 16, 2014
every 2 years in January, May and August from March 16, 2014
every 4 years in November on Tuesday the 2nd, 3rd, 4th, 5th, 6th, 7th or 8th of the month from March 16, 2014
yearly on the 1st, 5th and 21st of the month from March 16, 2014
yearly on Tuesday or Friday the 1st, 5th or 21st of the month from March 16, 2014
yearly on Tuesday, Wednesday and Friday from March 16, 2014
yearly on the 1st and 200th day from March 16, 2014
yearly in week 3 on Sunday from March 16, 2014
yearly in weeks 3, 20 and 30 on Sunday from March 16, 2014
weekly on Sunday from March 16, 2014
every 10 weeks on Sunday from March 16, 2014
weekly on Sunday in January, May and August from March 16, 2014
every 2 weeks on Sunday in January, May and August from March 16, 2014
weekly on the 1st, 5th and 21st of the month from March 16, 2014
weekly on Tuesday or Friday the 1st, 5th or 21st of the month from March 16, 2014
weekly on Tuesday, Wednesday and Friday from March 16, 2014
yearly on March 16 from March 16, 2014
every 2 years on March 16 from March 16, 2014
yearly on March 16 from March 16, 2014 for 5 times
yearly on March 16 from March 16, 2014 until December 31, 2012
hourly from March 16, 2014
every 10 hours from March 16, 2014
hourly in January, May and August from March 16, 2014
every 2 hours in January, May and August from March 16, 2014
hourly on the 1st, 5th and 21st of the month from March 16, 2014
hourly on Tuesday or Friday the 1st, 5th or 21st of the month from March 16, 2014
hourly on Tuesday, Wednesday and Friday from March 16, 2014

simshaun avatar Feb 24 '19 03:02 simshaun

What do you think about adding a parameter to the "transform" function, containing an array of elements to exclude?

public function transform(Rule $rule, $exclude = array())
if (!in_array('startDate', $exclude)) {
    $startDate = $rule->getStartDate();
    if ($startDate instanceof \DateTimeInterface) {
        $dateFormatted = $this->translator->trans('day_date', array('date' => $startDate->format('U')));
        $this->addFragment($this->translator->trans('from %date%', array('date' => $dateFormatted)));
    }
}

And why not the same thing for "until"?

libertjeremy avatar Mar 02 '19 21:03 libertjeremy

I love the idea of being able to make the text output more granular. For example, I like the idea of showing the day of the month on monthly events, and would like to see the time included for weekly events. Personally I wouldn't want to see the start date included, but overall I think it would be great if this could be configurable in some way to allow it to meet the needs of a particular site.

mandclu avatar Jan 16 '20 20:01 mandclu