Giter Site home page Giter Site logo

Daylight savings about php-rrule HOT 2 CLOSED

rlanvin avatar rlanvin commented on July 23, 2024
Daylight savings

from php-rrule.

Comments (2)

rlanvin avatar rlanvin commented on July 23, 2024

This is a good question, and admittedly the behavior can be a bit confusing.

If you ask the lib to produce occurrences at a certain time in a certain timezone (say, 14:30 in America/Toronto), all the results will be at 14:30 in America/Toronto. The actual offset with UTC doesn't matter. Say for example you have meeting every Monday at 8am. It'll still be at 8am during DST, won't it?

You can achieve the behavior you are a describing if you set the DTSTART in UTC and convert the occurrences on the fly. Because then the lib will work with absolute UTC times, but the meaning of the time in your local timezone (America/Toronto) will change based on the date. Example:

$rrule = new RRule(
	'RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR,SA,SU;UNTIL=20180331T000000Z',
	date_create('2018-03-10 13:30:00', new DateTimeZone('America/Toronto'))->setTimeZone(new DateTimeZone('UTC')) // force the start in UTC
);

foreach ( $rrule as $occurrence ) {
	echo $occurrence->setTimeZone(new DateTimeZone('America/Toronto'))->format('l jS F Y H:i:s e P'),"\n";
}

This will produce:

Saturday 10th March 2018 13:30:00 America/Toronto -05:00
Sunday 11th March 2018 14:30:00 America/Toronto -04:00
Monday 12th March 2018 14:30:00 America/Toronto -04:00
Tuesday 13th March 2018 14:30:00 America/Toronto -04:00

Does this answer your problem?

from php-rrule.

morinluc0 avatar morinluc0 commented on July 23, 2024

Yes it does answer my question, I will modify the my behavior to send in a UTC time.

Thank you for clearing up that confusion.

from php-rrule.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.