Skip to content

Day of Year breaks due to Daylight savings #101

Open
@tainegilliam

Description

@tainegilliam

Your Day Of Year Native code will fail between midnight and 1am during daylight savings.

My replacement was:

Math.floor( (new Date().setHours(2) - new Date(new Date().getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24 );

which forces the time for the day.

Alternatively:

Math.floor( (Date.UTC(year, month, day) - Date.UTC(year, 0, 0)) / 1000 / 60 / 60 / 24 )

The opposite code is quite simple, too:

new Date(year, 0 , dayOfYear)

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