Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added start date in TextTransformer #161

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

libertjeremy
Copy link
Contributor

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.

@simshaun
Copy link
Owner

simshaun commented Feb 24, 2019

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

@libertjeremy
Copy link
Contributor Author

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"?

@mandclu
Copy link

mandclu commented Jan 16, 2020

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.

@@ -14,7 +14,7 @@ public function __construct(TranslatorInterface $translator = null)
$this->translator = $translator ?: new Translator('en');
}

public function transform(Rule $rule)
public function transform(Rule $rule, $exclude = array())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function transform(Rule $rule, $exclude = array())
public function transform(Rule $rule, $exclude = [])

https://github.com/simshaun/recurr/blob/master/composer.json#L16

Old PHP 5.3 compat is not needed :) (https://github.com/wdes/coding-standard#rules-to-disable-for-php--54-compatibility)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants