Skip to content

time: add 1 month can sometimes add 2 months #10401

@eclivus

Description

@eclivus

Hello,

This might not e related to Go itself, but I noticed that when incrementing a date month by month go sometimes leaps a month.

package main

import "fmt"
import "time"

func main() {
        date := time.Date(2013,time.January,31,23,59,59,0,time.UTC)
        fmt.Println(date.String())
        date = date.AddDate(0,1,0)
        fmt.Println(date.String())
}

Output:
2013-01-31 23:59:59 +0000 UTC
2013-03-03 23:59:59 +0000 UTC

Go version: go1.4.2 linux/amd64
System: Ubuntu 14.04.1
https://play.golang.org/p/5msN0bykp8

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions