opensource-nepal / go-nepali

go-nepali is a go package containing features that will be useful for Nepali projects.
GNU General Public License v3.0
7 stars 5 forks source link

Invalid date conversion! #15

Closed sumanchapai closed 8 months ago

sumanchapai commented 8 months ago

Run the following code

package main

import (
    "fmt"

    "github.com/opensource-nepal/go-nepali/dateConverter"
)

type AD struct {
    year  int
    month int
    day   int
}

func main() {
    ads := []AD{
        {2024, 6, 13},
        {2024, 6, 14},
    }
    for _, ad := range ads {
        bs, err := dateConverter.EnglishToNepali(ad.year, ad.month, ad.day)
        if err != nil {
            panic(err)
        }
        fmt.Printf("%v-%v-%v-AD\n", ad.year, ad.month, ad.day)
        fmt.Printf("%v-%v-%v-BS\n", bs[0], bs[1], bs[2])
        fmt.Printf("\n\n")
    }
}

and you'll get as output

2024-6-13-AD
2081-2-31-BS

2024-6-14-AD
2081-3-1-BS

Note that conversion of 2024-6-13-AD is correct while the next day is not! 2024-6-14-AD should be 2081-2-32-BS!

image
aj3sh commented 8 months ago

Hi @sumanchapai, thank you for reporting the bug! I've created a PR to address the current issue. However, we've encountered inconsistent month data on various Patros after the year 2081. We'll look into the matter promptly.

sumanchapai commented 8 months ago

Thanks. It's interesting to know that there's no consistency. If it helps, here's the data scraped from hamropatro for till: https://github.com/sumanchapai/patro/tree/main/data

aj3sh commented 8 months ago

I've noticed that Hamropatro has a total of 367 days in the year 2087, so I don't believe it has the correct data. I appreciate your help though.

aj3sh commented 8 months ago

PR has been merged and created a new release with the tag v0.2.1. https://pkg.go.dev/github.com/opensource-nepal/go-nepali@v0.2.1