Skip to content

datetime_to_time reports incorrect date #3235

Description

@Feoramund

Context

  • Operating System & Odin Version: Linux 6.7.6, Odin commit 7df7fec

Expected Behavior

The following program should output a date of March 1st, but it reports February the 29th.

package main

import "core:fmt"
import "core:time"

main :: proc() {
	fmt.println(time.datetime_to_time(2024, 3, 1, 0, 0, 0))
}

Failure Information (for bugs)

The program prints this:

2024-02-29 00:00:00.000000000 +0000 UTC true

I think the procedure isn't taking into account leap years with regard to February's extra day, and the logic behind DAYS_PER_400_YEARS and the other calculations is sound, but it's starting the arithmetic modulo from the year minus 1970, which would give incorrect results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions