Coder Social home page Coder Social logo

yaa110 / go-persian-calendar Goto Github PK

View Code? Open in Web Editor NEW
202.0 6.0 25.0 115 KB

The implementation of Persian (Solar Hijri) Calendar in Go

Home Page: https://pkg.go.dev/github.com/yaa110/go-persian-calendar

License: MIT License

Go 100.00%
persian-calendar go golang golang-module jalali

go-persian-calendar's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

go-persian-calendar's Issues

پیشنهاد توسعه

سلام پیشنهادی دارم برای افزودن قابلیت نمایش رویداد به برنامه ای که توسعه دادید

الان که همه ی سیستم ها به اینترنت متصل هستند پیشنهاد میکنم ارتباط با ای پی آي های تقویم رو هم در این سورس خوب پیاده سازی کنید
خودم از این سرویس زیاد استفاده میکنم


وب سرویس تقویم فارسی

اطلاعات خوبی ارائه میده مثل وقایع و مناسبت های هر روز و دریافت رویداد در حالت شمسی و قمری و میلادی

Formatting RFC3339

The main time package when timezone is UTC formats the date in RFC3339 like this:
2019-10-10T10:20:33Z
and for example for Tehran timezone formats like this:
2019-10-10T10:20:33+03:30

But your package for UTC acts as other timezones and formats as
1398-08-15T10:20:22+00:00

I think for consistency with main package you should format same as main time package

using ptime as gorm type

hey
first i wanna thank for your great repo.
second i have a question
is it possible to use ptime as type for sql database ?
i'm using gorm to connect database

type User struct {
	gorm.Model
	DeletedAt   gorm.DeletedAt `gorm:"uniqueIndex:national_id_deleted_at_idx;uniqueIndex:phone_number_deleted_at_idx"`
	FirstName   string         `gorm:"type:varchar(50);index;not null;"`
	LastName    string         `gorm:"type:varchar(50);index;not null;"`
	NationalID  string         `gorm:"type:varchar(10);index;not null;uniqueIndex:national_id_deleted_at_idx"`
	PhoneNumber uint           `gorm:"type:BIGINT(10)index;not null;uniqueIndex:phone_number_deleted_at_idx"`
	BirthDate   ptime.Time     `gorm:"index;not null;"`
	Gender      Gender         `gorm:"not null;default:'active'"`
	Status      Status         `gorm:"not null;"`
	Children    []Child        `gorm:"foreignKey:ParentID"`
}

when i try to do this and migrate database i get this error

[error] invalid field found for struct user.User's field BirthDate: define a valid foreign key for relations or implement the Valuer/Scanner interface      

AddDate() not works correctly

While appreciating the project, AddDate() not works correctly. As a sample, today is 2023-06-11 OR 1402/03/21

By using this sample (the dates of the days of the future years):

func main() {
	pt := pTime.Now()
	utility.UFileDelete("dates.txt")
	for i := 0; i < 3650; i++ {
		pd := pt.AddDate(0, 0, i)
		utility.UFileAppend("dates.txt", strconv.Itoa(i)+" : "+pd.Format("yyyy/MM/dd  E  MMMMM  D/RD  w/rw")+"\n                                             "+pd.Time().String()+"\n", false)
	}
}

The output is (end of 1402):

image

Today + 286 -> 1402/12/28 2024-03-18

Today + 287 -> 1402/12/29 2024-03-19
Today + 288 -> 1402/12/29 2024-03-19
Today + 289 -> 1403/01/01 2024-03-20
Today + 290 -> 1403/01/01 2024-03-20

Today + 291 -> 1403/01/02 2024-03-21


But with updating the code as below by adding the days to standard time package:

func main() {
	t := 10 * 365
	now := time.Now()
	utility.UFileDelete("dates.txt")
	for i := 0; i < t; i++ {
		p := now.AddDate(0, 0, i)
		pt := pTime.Unix(p.Unix(), 0)
		utility.UFileAppend("dates.txt", strconv.Itoa(i)+" : "+pt.Format("yyyy/MM/dd  E  MMMMM  D/RD  w/rw")+"\n                                                  "+pt.Time().Format(time.UnixDate)+"\n", false)
	}
}
image

...
Today + 281 -> 1402/12/28 2024-03-18
Today + 282 -> 1402/12/29 2024-03-19
Today + 283 -> 1403/01/01 2024-03-20
Today + 284 -> 1403/01/02 2024-03-21
...
Today + 286 -> 1403/01/04 2024-03-23
Today + 287 -> 1403/01/05 2024-03-24
Today + 288 -> 1403/01/06 2024-03-25
Today + 289 -> 1403/01/07 2024-03-26
Today + 290 -> 1403/01/08 2024-03-27
...

Daylight saving time

Can not calculate correctly Sub Days with AddDate function
example set the time to 1400-01-01
and use FirstWeekDay function to return
and you see return 1400-06-26 instead of 1400-06-27
I think the problem is with the time zone (+04:30 and +03:30)

t.nsec length

Hi Navid

strconv.Itoa(t.nsec) string length rarely goes less than 6 and because of you trying to get a string with lenght 6 of it run time error happening, the problematic code is :

"{ms}", "." + strconv.Itoa(t.nsec)[:6],

and the error is :
panic: runtime error: slice bounds out of range [:6] with length 5

I fixed it in my fork by adding "0" charcter as needed to end of it's string.

Good Luck.

panic in Format

The code will going to panic if the input value of ptime.New() is the zero value of time.Time
line 222: func (m Month) String() string {
return months[m-1]
}
cause when the time equals to "0001-01-01 00:01" the month array is going to have '-1' index and it is going to panic

FirstDayOfMonth() method

I think The FirstDayOfMonth() method must be returns the first day of month and reset the time to 00:00:00, but the method only reset the date and keeps original time

Validate and parse time

Missing two important method!

  • no method for validating date!
  • no method for parse string date!

thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.