Earlier today, I saw on Lemmy that comments made within the last hour since DST were now in the negatives since time had rolled back. If a database uses time like this for search operations, would that interfere with them? Could it corrupt the database?

  • NotAnOtter@lemmus.org
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 days ago

    Almost all databases store time in Unix time stamps, which is just a number counting up. Then the various consumers of that value, such as clocks, convert it based on their need (such as time savings, geographic region, etc). But someone in florida has the same unix timestamp at a given instant as someone in Africa.

  • trxxruraxvr@lemmy.world
    link
    fedilink
    arrow-up
    105
    ·
    edit-2
    4 days ago

    It depends on the database. But it’s common practice to store values in UTC, which doesn’t have DST, and only display in the user’s timezone. What you saw was probaby only a bug on the front end, but not database corruption.

  • Mantzy81@aussie.zone
    link
    fedilink
    English
    arrow-up
    41
    ·
    4 days ago

    UTC homie. It’s what the databases runs on. Local timezones and DST are all based off of that not some arbitrary local variation of time.

  • kingofras@lemmy.world
    link
    fedilink
    arrow-up
    19
    arrow-down
    1
    ·
    4 days ago

    This is poor Lemmy programming, has nothing do with DST. You’ll often see if you’re posting a comment it will say “in 3 seconds”, meaning in the future. It’s because of how the frontend calculates the relative time based on a db timestamp against the local clock of your computer… which are beginner programmer mistakes from the late 90’s.

    Slightly off topic below.

    The 2 blokes programming this are not very good and since they are now beginning to peddle violence inciting garbage they can stuff their monthly donation too.

      • kingofras@lemmy.world
        link
        fedilink
        arrow-up
        6
        arrow-down
        1
        ·
        4 days ago

        Well they don’t peddle violence directly of course that would be incriminating. They are setting up their instance moderation rules so that burning down the western democracies is encouraged.

  • Pissmidget@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    4 days ago

    I’ve heard some companies where time is critical make extra certain by closing for any writes during the time change.

    Most places it is sufficient to stick to UTC.

    An online storefront for refilling cafeteria cards I know of are so careful they close every night…

  • dasrael@lemmy.zip
    link
    fedilink
    arrow-up
    3
    ·
    4 days ago

    Like most anything, there are methods and designs (best practices) which if followed, will prevent you from falling into pitfalls like that. It’s generally only a problem if you design things to use time and not account for it. And as for the time changing while an operation is currently occurring, this again, is what transactions and other “atomic” type of operations are designed to account for. There is a lot about computer science where you need to make sure the sand you’re standing on isn’t shifting when you’re on it.

  • melsaskca@lemmy.ca
    link
    fedilink
    arrow-up
    2
    ·
    4 days ago

    If the field is defined well it shouldn’t corrupt the database but it may affect sorting during that timespan.