Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-couto committed Aug 25, 2021
2 parents 38fffcd + 25efdfb commit f3d97f4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ ConvertFloat64ToString4Decimal(value string) Return float64
ConvertStringToFloat64(value string) Return float64
ConvertStringToFloatScale2Comma(value string) Return float64
ConvertStringToFloatScale2FormatNumber(value string) Return float64
ConvertStringToFloatScale2(value string) float64
ConvertStringToFloatScale2(value string) Return float64
ConvertFloatToBrMoneyString(value float64) Return string
```

### ftp.go
Expand Down
9 changes: 8 additions & 1 deletion datetime.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const LAYOUT_HHMMSS = "150405"
const LAYOUT_HH = "15"
const LAYOUT_HH_MM_SS = "15:04:05"
const LAYOUT_YYYY_MM_DDTHH_MM_SS_000Z = "2006-01-02T15:04:05.000Z"
const LAYOUT_YYYY_MM_DDTHH_MM_SS_000 = "2006-01-02 15:04:05"
const LAYOUT_YYYY_MM_DDTHH_MM_SS_000 = "2006-01-02T15:04:05.000"

/*
ConvertStringToTimeLayoutDDMMYYYY
Expand Down Expand Up @@ -143,6 +143,13 @@ func ConvertStringToTimeLayoutYYYY_MM_DDTHH_MM_SS_000(value string) time.Time {
return t
}

/*
ConvertTimeToStringLayoutYYYY_MM_DDTHH_MM_SS_000
*/
func ConvertTimeToStringLayoutYYYY_MM_DDTHH_MM_SS_000(date time.Time) string {
return date.Format(LAYOUT_YYYY_MM_DDTHH_MM_SS_000)
}

/*
ConvertStringToTimeLayoutHHMMSS
*/
Expand Down
29 changes: 29 additions & 0 deletions float.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,32 @@ func ConvertStringToFloatScale2(value string) float64 {
s, _ := strconv.ParseFloat(value, 64)
return s
}

/*
ConvertFloatToBrMoneyString
*/
func ConvertFloatToBrMoneyString(value float64) string{
str := fmt.Sprintf("%.2f", value)
split := strings.Split(str, ".")

number := split[0]
decimal := "00"
if len(split) > 0 {
decimal = split[1]
}

var values []string

if len(number) < 3 {
values = append(values, number)
} else {
for i := len(number); i > 0; i -= 3 {
j := i-3
if j < 0 {
j = 0
}
values = append([]string{number[j:i]}, values...)
}
}
return strings.Join(values[:], ".") + `,` + decimal
}

0 comments on commit f3d97f4

Please sign in to comment.