├── .gitignore ├── README.md ├── bin.zip ├── bongo ├── build ├── main.go ├── main_test.go ├── screenshot-bn.png └── screenshot-en.png /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | .vscode/ 4 | ./bongo 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Bongo 2 | ======== 3 | Terminal based bengali calendar 4 | 5 | ![Bongo screenshot](screenshot-bn.png) 6 | 7 | # Installation 8 | 9 | 1. [Download binary from here](https://github.com/thedevsaddam/bongo/raw/master/bin.zip) 10 | 1. Unzip the bin file 11 | 1. For unix user `cp your_bin_file /usr/local/bin/bongo` 12 | 1. Make the file executable `chmod +x /usr/local/bin/bongo` 13 | 14 | # Usage 15 | * `$ bongo` print bengali ponjika in bengali font 16 | * `$ bongo -p` print bengali ponjika in english phonetic. 17 | 18 | ![Bongo phonetic screenshot](screenshot-en.png) 19 | 20 | # Special thanks 21 | * [Nuhil Mehdy](https://github.com/nuhil) 22 | * [Ahmed shamim](https://github.com/me-shaon) 23 | * [Sajib Sikder](https://github.com/mhshajib) 24 | -------------------------------------------------------------------------------- /bin.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedevsaddam/bongo/77381cf136df68c24565bdf0fe7e83d007443d4e/bin.zip -------------------------------------------------------------------------------- /bongo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedevsaddam/bongo/77381cf136df68c24565bdf0fe7e83d007443d4e/bongo -------------------------------------------------------------------------------- /build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #MAC OS 4 | export GOARCH="386" 5 | export GOOS="darwin" 6 | export CGO_ENABLED=1 7 | go build -o mac_386 -v 8 | 9 | export GOARCH="amd64" 10 | export GOOS="darwin" 11 | export CGO_ENABLED=1 12 | go build -o mac_amd64 -v 13 | 14 | #LINUX 15 | export GOARCH="amd64" 16 | export GOOS="linux" 17 | export CGO_ENABLED=0 18 | go build -o linux_amd64 -v 19 | 20 | export GOARCH="386" 21 | export GOOS="linux" 22 | export CGO_ENABLED=0 23 | go build -o linux_386 -v 24 | 25 | #FREEBSD 26 | export GOARCH="amd64" 27 | export GOOS="freebsd" 28 | export CGO_ENABLED=0 29 | go build -o freebsd_amd64 -v 30 | 31 | export GOARCH="386" 32 | export GOOS="freebsd" 33 | export CGO_ENABLED=1 34 | go build -o freebsd_386 -v 35 | 36 | #OPENBSD 37 | export GOARCH="amd64" 38 | export GOOS="openbsd" 39 | export CGO_ENABLED=0 40 | go build -o freebsd_amd64 -v 41 | 42 | export GOARCH="386" 43 | export GOOS="openbsd" 44 | export CGO_ENABLED=0 45 | go build -o freebsd_386 -v 46 | 47 | #WINDOWS 48 | export GOARCH="386" 49 | export GOOS="windows" 50 | export CGO_ENABLED=0 51 | go build -o windows_386.exe -v 52 | 53 | export GOARCH="amd64" 54 | export GOOS="windows" 55 | export CGO_ENABLED=0 56 | go build -o windows_amd64.exe -v 57 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | "time" 8 | 9 | "github.com/thedevsaddam/ponjika" 10 | ) 11 | 12 | func main() { 13 | now := time.Now() 14 | p := ponjika.New(now) 15 | mnthTotalDys := p.TotalDays 16 | crntDate := p.Date 17 | crntDateIndx := int(now.Weekday()) 18 | frstDateIndx := firstDayIndex(crntDate, crntDateIndx) 19 | 20 | calender := [6][7]int{} 21 | 22 | row := 0 23 | col := frstDateIndx 24 | for i := 1; i <= mnthTotalDys; i++ { 25 | calender[row][col] = i 26 | 27 | col = col + 1 28 | if col > 6 { 29 | row = row + 1 30 | col = 0 31 | } 32 | } 33 | 34 | isPh := flag.Bool("p", false, "show bengali calendar in english phonetic") 35 | flag.Parse() 36 | 37 | if *isPh { 38 | heading := fmt.Sprintf("\t%s %s", p.BengaliMonth.Phonetic, p.BengaliYear.Phonetic) 39 | fmt.Println(bold(heading)) 40 | phoneticBengaliCalendar(calender, crntDate) 41 | os.Exit(0) 42 | } 43 | heading := fmt.Sprintf("\t %s %s", p.BengaliMonth.Bengali, p.BengaliYear.Bengali) 44 | fmt.Println(bold(heading)) 45 | bengaliCalender(calender, crntDate) 46 | } 47 | 48 | func bengaliCalender(calender [6][7]int, today int) { 49 | fmt.Println("রবি সোম মঙ্গল বুধ বৃহ শুক্র শনি") 50 | for i := 0; i < len(calender); i++ { 51 | for j := 0; j < 7; j++ { 52 | dt := calender[i][j] 53 | if dt != 0 { 54 | if dt > 9 { 55 | if dt == today { 56 | fmt.Print(highlight(enToBnNumber(dt)), " ") 57 | } else { 58 | fmt.Print(enToBnNumber(dt), " ") 59 | } 60 | } else { 61 | if dt == today { 62 | fmt.Print(highlight(enToBnNumber(dt)), " ") 63 | } else { 64 | fmt.Print(enToBnNumber(dt), " ") 65 | } 66 | } 67 | } else { 68 | fmt.Print(" ") 69 | } 70 | } 71 | fmt.Println() 72 | } 73 | } 74 | 75 | func phoneticBengaliCalendar(calender [6][7]int, today int) { 76 | fmt.Println("Su Mo Tu We Th Fr Sa") 77 | for i := 0; i < len(calender); i++ { 78 | for j := 0; j < 7; j++ { 79 | dt := calender[i][j] 80 | if dt != 0 { 81 | if dt > 9 { 82 | if dt == today { 83 | fmt.Print(highlight(fmt.Sprintf("%d", dt)), " ") 84 | } else { 85 | fmt.Print(dt, " ") 86 | } 87 | } else { 88 | if dt == today { 89 | fmt.Print(highlight(fmt.Sprintf("%d", dt)), " ") 90 | } else { 91 | fmt.Print(dt, " ") 92 | } 93 | } 94 | } else { 95 | fmt.Print(" ") 96 | } 97 | } 98 | fmt.Println() 99 | } 100 | } 101 | 102 | // firstDayIndex return the months first day index 103 | func firstDayIndex(date, dateIndex int) int { 104 | position := (date - 1) % 7 105 | offset := dateIndex - position 106 | 107 | return ((offset + 7) % 7) 108 | } 109 | 110 | // enToBnNumber covert english number to bengali number String 111 | func enToBnNumber(d int) string { 112 | var o string 113 | ds := fmt.Sprintf("%v", d) 114 | bdmap := map[string]string{ 115 | "1": "১", 116 | "2": "২", 117 | "3": "৩", 118 | "4": "৪", 119 | "5": "৫", 120 | "6": "৬", 121 | "7": "৭", 122 | "8": "৮", 123 | "9": "৯", 124 | "0": "০", 125 | } 126 | for i := 0; i < len(ds); i++ { 127 | o += bdmap[string(ds[i])] 128 | } 129 | return o 130 | } 131 | 132 | func highlight(in string) string { 133 | lg := "\033[1;32m" // light green 134 | nc := "\033[0m" 135 | return fmt.Sprintf("%s%s%s", lg, in, nc) 136 | } 137 | 138 | func bold(in string) string { 139 | bld := "\033[1m" // bold 140 | nb := "\033[0m" 141 | return fmt.Sprintf("%s%s%s", bld, in, nb) 142 | } 143 | -------------------------------------------------------------------------------- /main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func Test_firstDayIndex(t *testing.T) { 6 | testCases := []struct { 7 | Tag string 8 | Date, DateIndex, FirstDayIndex int 9 | }{ 10 | { 11 | Tag: "benglai saal 1425, 1 boisakh expected first day zero based index is 6", 12 | Date: 1, 13 | DateIndex: 6, 14 | FirstDayIndex: 6, 15 | }, 16 | { 17 | Tag: "benglai saal 1425, 16 joishta expected first day zero based index is 2", 18 | Date: 16, 19 | DateIndex: 3, 20 | FirstDayIndex: 2, 21 | }, 22 | { 23 | Tag: "benglai saal 1425, 13 kartik expected first day zero based index is 0", 24 | Date: 13, 25 | DateIndex: 0, 26 | FirstDayIndex: 2, 27 | }, 28 | { 29 | Tag: "benglai saal 1425, 25 poush expected first day zero based index is 2", 30 | Date: 25, 31 | DateIndex: 2, 32 | FirstDayIndex: 6, 33 | }, 34 | { 35 | Tag: "english year 2018, 28 march expected first day zero based index is 3", 36 | Date: 28, 37 | DateIndex: 3, 38 | FirstDayIndex: 4, 39 | }, 40 | } 41 | 42 | for _, tc := range testCases { 43 | if r := firstDayIndex(tc.Date, tc.DateIndex); r != tc.FirstDayIndex { 44 | t.Errorf("firstday index failed\nExpected: %d Got: %d", tc.FirstDayIndex, r) 45 | } 46 | } 47 | } 48 | 49 | func Test_enToBnNumber(t *testing.T) { 50 | testCases := map[int]string{ 51 | 1: "১", 52 | 2: "২", 53 | 3: "৩", 54 | 4: "৪", 55 | 5: "৫", 56 | 6: "৬", 57 | 7: "৭", 58 | 8: "৮", 59 | 9: "৯", 60 | 0: "০", 61 | 2018: "২০১৮", 62 | } 63 | for en, bn := range testCases { 64 | if r := enToBnNumber(en); r != bn { 65 | t.Error("e2dDigit failed", "expected: ", bn, " got: ", r) 66 | } 67 | } 68 | } 69 | 70 | func Test_highlight(t *testing.T) { 71 | testCases := map[string]string{ 72 | "1": "\033[1;32m1\033[0m", 73 | "2": "\033[1;32m2\033[0m", 74 | "foo": "\033[1;32mfoo\033[0m", 75 | } 76 | 77 | for in, out := range testCases { 78 | if r := highlight(in); r != out { 79 | t.Error("highlight failed", "expected: ", out, " got: ", r) 80 | } 81 | } 82 | } 83 | 84 | func Test_bold(t *testing.T) { 85 | testCases := map[string]string{ 86 | "1": "\033[1m1\033[0m", 87 | "2": "\033[1m2\033[0m", 88 | "foo": "\033[1mfoo\033[0m", 89 | } 90 | 91 | for in, out := range testCases { 92 | if r := bold(in); r != out { 93 | t.Error("bold failed", "expected: ", out, " got: ", r) 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /screenshot-bn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedevsaddam/bongo/77381cf136df68c24565bdf0fe7e83d007443d4e/screenshot-bn.png -------------------------------------------------------------------------------- /screenshot-en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/thedevsaddam/bongo/77381cf136df68c24565bdf0fe7e83d007443d4e/screenshot-en.png --------------------------------------------------------------------------------