opensource-nepal / go-nepali Goto Github PK
View Code? Open in Web Editor NEWgo-nepali is a go package containing features that will be useful for Nepali projects.
License: GNU General Public License v3.0
go-nepali is a go package containing features that will be useful for Nepali projects.
License: GNU General Public License v3.0
Let's implement CLI for date conversion, English to Nepali (AD to BS), and Nepali to English (BS to AD).
An example of a CLI would be:
ad2bs 2023-04-29
# Output: 2080-01-16
bs2ad 2080-01-16
# Output: 2023-04-29
In our current date converter code, we are using different reference points of date. The reference points are 2000/01/01 BS with 1943/4/14 AD and 1944/01/01 AD with 2000/09/17 BS. They are used inside the code as they are hard-coded.
With this, the maintainability of the code gets difficult. So the solution is to use one reference point of date, 2000/01/01 BS with 1943/4/14 AD which should be easily changeable in the future.
Support Nepali months and weekdays strings for formatting.
Eg.
Months: Baishak, Jestha, ..., Chaitra
Week Days: Sunday, Monday, ..., Saturday
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!
The current version for this project has been set to 1.19. Let's upgrade the go version to the latest.
Support Nepali months and weekdays strings for parsing.
Eg.
Months: Baishak, Jestha, ..., Chaitra
Week Days: Sunday, Monday, ..., Saturday
Remove the absolute imports from the source code.
Eg: https://github.com/orgs/opensource-nepal/go-nepali/dateConverter
Add support for GO like Parse
and Format
layouts (date and time format).
Eg.
const layout = "Jan 2, 2006 at 3:04pm (MST)"
tm, _ := time.Parse(layout, "Feb 4, 2014 at 6:05pm (PST)")
tm.Format("2006-02-01")
The current documentation is weak and do not covers all the features of nepalitime
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.