Skip to content

Commit 0ef6d20

Browse files
committed
Fix buffer allocation and test string in KurdishDate
Corrected buffer allocation in KFormat to use bufSize instead of layout length, ensuring sufficient capacity. Also updated test to use a zero-width non-joiner in the Kurdish month name for accuracy.
1 parent 5ca1888 commit 0ef6d20

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

format.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (k KurdishDate) KFormat(layout string) (string, error) {
4343
if bufSize < minBufSize { // minimum buffer size
4444
bufSize = minBufSize
4545
}
46-
b := make([]byte, 0, len(layout))
46+
b := make([]byte, 0, bufSize)
4747

4848
b, err := k.kAppendFormat(b, layout)
4949
return string(b), err
@@ -53,10 +53,10 @@ func (k KurdishDate) KFormat(layout string) (string, error) {
5353
// representation to b and returns the extended buffer.
5454
func (k KurdishDate) kAppendFormat(b []byte, layout string) ([]byte, error) {
5555
var (
56-
year int = -1
56+
year = -1
5757
month int
5858
day int
59-
hour int = -1
59+
hour = -1
6060
min int
6161
sec int
6262
)

kurdical_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestGregorianToKurdish(t *testing.T) {
104104
Month: 10,
105105
Day: 11,
106106
Weekday: 2,
107-
MonthName: "به‌فرانبار",
107+
MonthName: "به\u200cفرانبار",
108108
Dialect: Sorani,
109109
Epoch: MedianKingdom,
110110
},

0 commit comments

Comments
 (0)