Coder Social home page Coder Social logo

Comments (5)

coltfred avatar coltfred commented on August 18, 2024

@Kijewski The time that the device was created is in UTC and the adjustment made by util::local_offset() should match the offset of the system that ironhide is being run on. I think this is what I would expect to be the case.

Can you provide a clarifying example if you do not agree?

from ironhide.

Kijewski avatar Kijewski commented on August 18, 2024

util::local_offset() returns the current offset. For me right now that is UTC+1 (CET), before 2022-10-30 it was UTC+2 (CEST). So for any device created on 2022-10-29 the time will be off by an hour, right?

from ironhide.

cjyar avatar cjyar commented on August 18, 2024

Playing with this issue a little bit, we ended up in C. This code:

#include <stdio.h>
#include <time.h>

int main()
{
    struct tm *ptr;
    struct tm *ptr_t;

    /* Nov 5, midnight, GMT */
    time_t t = 1667606400;
    ptr = localtime(&t);
    printf("%s", asctime(ptr));

    /* Nov 7, midnight, GMT */
    time_t tt = 1667779200;
    ptr_t = localtime(&tt);
    printf("%s", asctime(ptr_t));
    return 0;
}

produces this output when run on a laptop in MST currently:

Fri Nov  4 18:00:00 2022
Sun Nov  6 17:00:00 2022

from ironhide.

skeet70 avatar skeet70 commented on August 18, 2024

So yes, we should do this. In addition to #83 I think that means using find_local_time_type to get the offset for the created timestamp.

from ironhide.

Kijewski avatar Kijewski commented on August 18, 2024

You can use tz::DateTime::from_total_nanoseconds() + tzdb::local_tz() to convert a unix timestamp into a timestamp in the correct time zone, and let from_total_nanoseconds() accurately tell if it's DST or not.

from ironhide.

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.