Giter VIP home page Giter VIP logo

datetime's People

Contributors

actions-user avatar gertvdb avatar

Watchers

 avatar  avatar  avatar  avatar

datetime's Issues

Issue with timezones that have daylight savings time (DST)

Detailed description

When modifying a DateTimePlus (for example by adding days), the library is unable to consider DST because it is unaware of the timezone. The offset alone is not enough to identify the timezone and the need to adjust for DST.

Context

As we usually work in Europe/Brussels timezone - which has DST - we always will have this problem when modifying a DateTimePlus from summertime to wintertime and vice versa.

Possible implementation

Add a FormatWithTimezone that does what it says: include the timezone (iso the offset).

Your environment

how to reproduce:

// summertime ends at 27/10/2024 when 03:00 becomes 02:00
$summerTime = DateTimePlus::from("2024-10-27T00:00:00+02:00", FormatWithTimezone::ATOM);
// add 1 day
$winterTime = $summerTime->add(0, 0, 1); 
$winterFormatted = $winterTime->formatPlus("Y-MM-dd'T'HH:mm:ss.SSSZZZZZ'", 'nl_BE', new \DateTimeZone("Europe/Brussels"));

echo $winterFormatted;
// expected: 2024-10-28T00:00:00.000+01:00
// actual: 2024-10-27T23:00:00.000+01:00

Add FromTimestamp Method

Add a method to create DateTimePlus from timestamp since a timestamp is always in UTC timezone.

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.