yohang / calendr Goto Github PK
View Code? Open in Web Editor NEWThe missing PHP 5.3+ calendar management library.
Home Page: http:/yohan.giarel.li/CalendR
License: MIT License
The missing PHP 5.3+ calendar management library.
Home Page: http:/yohan.giarel.li/CalendR
License: MIT License
I'm using this bundle with Symfony 2.8 and the only deprecation I found until now is the following
The Symfony\Component\OptionsResolver\OptionsResolver::replaceDefaults method is deprecated since version 2.6 and will be removed in 3.0. Use the clear() and setDefaults() methods instead
.
So, using setDefaults
should be fine, along with allowing ^3.0
in composer.json
This is a dump of February 2015:
Month {#2306 ▼
-current: null
#begin: DateTime {#2288 ▼
+"date": "2015-02-01 00:00:00"
+"timezone_type": 3
+"timezone": "Europe/Rome"
}
#end: DateTime {#2295 ▼
+"date": "2015-03-01 00:00:00"
+"timezone_type": 3
+"timezone": "Europe/Rome"
}
#firstWeekday: 1
}
I'd expect to see it ending 2015-02-28, not 2015-03-01.
Hi,
How do you show multi-day events on a calendar? The following piece of code correctly shows events which start on a particular date, but it doesn't show events which span multiple days. I'm using the Indexed Event Collection.
<?php foreach ($eventCollection->find($day) as $event): ?>
<li><?= $event ?></li>
<?php endforeach ?>
Thanks
Calendar class uses PeriodInterface
as return type for getYear
, getMonth
, getWeek
.
Such method should return, respectively, Year
, Month
, Week
, that are implementing \Iterator
.
With the current code, a call to foreach (new Calendar)->getMonth()
is marked as invalid by phpstorm ("Can not iterate PeriodInterface").
Is this app still working with php 7 and Laravel 5.8?
Because non of the site's bolierplate code is working.
I cannot biuld the calendar, it only renders the day names, Mon to Fri repeteadly.
thanks.
I've just lost 15 minutes wondering why my events weren't retrieved, in the end it was just my event provider which wasn't properly loaded. Could you throw an error when there's no provider specified?
Hi,
Period
doesn't have the same meaning in English and in French. Here is my best example: http://www.tampax.co.uk/en-GB/periodCalendar/periodCalendar.aspx.
There is some minor changes to do in the documentation :
Well, indeed this repo has no releases.
The last tag, anyway, was published back in 2019, so it's currently not possible to install this library on PHP 8 (the only major version currently supported) unless you use dev-master (or the ^3.0@dev alias).
So, it would be nice to get a new tag and a new release.
Why is the first weekday option only working on the Month iterator? When using getWeek(...) and looping through the dates, it always starts with Monday.When using getMonth(...) I get the expected result, the first day is whatever getFirstWeekday() is.
First of all. Great works its very awesome.
But i do some experiments and now i try to mark the today in calendar but i can't find any ways to do that....
Any help solutions for that??
Thanks
I just began to add hours to days, so we can have a nice 1 day view
https://github.com/lsv/CalendR/tree/hours
But I just got stucked because of the iteration on the month get really weird.
$start = new \DateTime('2013-01-01');
$month = new Month($start);
$i = 0;
foreach ($month as $week) {
$this->assertInstanceOf('CalendR\\Period\\Week', $week);
foreach ($week as $day) {
/** @var Day $day */
$this->assertSame($start->format('d-m-Y'), $day->getBegin()->format('d-m-Y'));
$start->add(new \DateInterval('P1D'));
$i++;
}
}
$this->assertEquals($i, 31);
This actually gives me 35 in the last assert, and all assertSame is 1 day behind all the time.
Would be handy I will be able to set the day for Month Period for iterate from actual day or the second option to solve this, class Range must implements \Iterator.
Using an instance of "Twig_Function_Method" for function "calendr_year" is deprecated since version 1.21. Use Twig_SimpleFunction instead.
Using an instance of "Twig_Function_Method" for function "calendr_month" is deprecated since version 1.21. Use Twig_SimpleFunction instead.
Using an instance of "Twig_Function_Method" for function "calendr_week" is deprecated since version 1.21. Use Twig_SimpleFunction instead.
Using an instance of "Twig_Function_Method" for function "calendr_day" is deprecated since version 1.21. Use Twig_SimpleFunction instead.
Using an instance of "Twig_Function_Method" for function "calendr_events" is deprecated since version 1.21. Use Twig_SimpleFunction instead.
Hi all!
I'm working with this library for a while (It works like a charm BTW), and I really missing what I think is a good new feature.
The default Event model, does not have the possibility to hold a "data" (Where data is whatever you need, it could be an object, an array or a primitive), and you always have to extend default Entity to include your custom data.
While i think this is good for advanced use cases, i think for simple use cases, having a "bag" where store whatever you need (a title, a status, or even an array with more complex data) without having to extend the default model would be perfect.
I don't know what you think, if you agree I can work on a pull request.
Thanks you for your work
I noticed when printing out each day of the week and corresponding events for them that weeks seem to start on Monday and end on Sunday. In the US, weeks on calendars typically start on Sunday and end on Saturday. Is there a way to shift this so I can print out weekdays Sunday through Saturday the US style way?
There is no commit for 1.5 year and the last answer to an issue was 2 years ago.
I went through your "documentation". Your examples lack of parenthesis so I get parse errors, and on top of that, I get fatal errors as well:
Fatal error: Call to undefined method CalendR\Period\Month::containsPeriod()
With the current implementation for Month->extendedMonth() the period ends on midnight saturday to sunday. This means using this Period in for instance $factory->getEvents($month->extendedMonth()) misses these events. Shouldn't the Period end on midnight sunday to monday?
$factory = new \CalendR\Calendar;
$month = $factory->getMonth(2020, 6);
$events = $factory->getEvents($month);
CalendR\Event\Exception\NoProviderFound: in file /home/wwwroot/akstest.gewu.pro/tooth/vendor/yohang/calendr/src/CalendR/Event/Manager.php on line 68
For year 2012 and month 12, day 31 in not included in the month.
If I'll make this check, it will return false:
$month->includes($day); // where $day is 2012-12-31
In your code you have the following:
public function includes(PeriodInterface $period, $strict = true)
{
if (true === $strict) {
return
$this->contains($period->getBegin()) &&
$this->contains($period->getEnd());
}
...
This check $this->contains($period->getBegin()) will return TRUE, but this one will return FALSE: $this->contains($period->getEnd()). This is because ->getEnd() returns the next day.
CalendR\Period\Day('begin'=>DateTime('date'=>'2012-12-31 00:00:00', 'timezone_type'=> 3, 'timezone'=> ... ), 'end'=>DateTime('date'=>'2013-01-01 00:00:00', 'timezone_type'=> 3, 'timezone'=> ... ))
sprintf in PeriodAbstract::__construct is missing an argument and thus breaks if $firstWeekday is out of bounds. Additionally, the message implies that 6 == Friday which isn't true. It should be:
sprintf('"%s" is not a valid day. Days are between 0 (Sunday) and 6 (Saturday)', $firstWeekday)
Hello Yohang
Is it at all possible that this package could support Carbon along side the Native \DateTime class, because The laravel elougent ORM is using this package out of the box.
And Carbon is a nice wrapper around the DateTime class
It's A LOT of work yeah i know, but it could be possible.
PROBLEM
foreach tries to iterate over null.
FIX:
protected $events could be initialised as array()
Shouldn't this method return true if $date->format('U') == $this->begin->format('U')?
Please
object(CalendR\Period\Week)#567 (4) {
["current":"CalendR\Period\Week":private]=>
NULL
["begin":protected]=>
object(DateTime)#566 (3) {
["date"]=>
string(19) "2012-04-02 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["end":protected]=>
object(DateTime)#587 (3) {
["date"]=>
string(19) "2012-04-09 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["firstWeekday":protected]=>
int(1)
}
when I go echo $day->begin->date I get Cannot access protected property CalendR\Period\Day::$begin
It's the second time I'm using Calendr for two different projects and I still get this error :
The first time I used Calendr I had a PHP 5.4 server so I could use traits. My repository was declared as your first example code. To avoid the above error, I just added implements ProviderInterface
to the EventRepository
declaration and it was done.
Now my server is under PHP 5.3 so I'm using the second way provided on the doc. But, using this second way doesn't provides all the methods required by ProviderInterface
and, at this point, I'm stuck…
Hi!
I need to show the first and last day of the week with the format {{ first_monday_number }}-{{ last_saturday_number }} {{ month_name }}
. Example with the week number 24: 2017-06-12 to 2017-06-18
<?php
$year = $request->query->has('year') ? $request->query->get('year') : date('Y');
$weeknum = $request->query->has('weeknum') ? $request->query->get('weeknum') : date('W');
$week = $this->get('calendr')->getWeek($year, $weeknum);
$weekEvents = $this->get('calendr')->getEvents($week);
In the twig template:
{{ week.begin.format('j') }} - {{ week.end.format('j') }} of {{ week.format('F') }}
The problem is in {{ week.end.format('j') }}
, print "12 - 19 of June" and I need the last day to be on Saturday: 12 - 17 of June.
How can I get the correct date?
Thanks,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.