formathelper

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2024 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CeilFloat

func CeilFloat[T ConvertableToFloat](value T, decimalPlaces int) T

CeilFloat 函数将浮点数向上舍入到指定小数位数

func FirstUpper

func FirstUpper(s string) string

func FloorFloat

func FloorFloat[T ConvertableToFloat](value T, decimalPlaces int) T

FloorFloat 函数将浮点数向下舍入到指定小数位数

func FormatDate

func FormatDate(t time.Time) string

FormatDate 格式化时间为 YYYY-MM-DD 格式

func FormatDateTime

func FormatDateTime(t time.Time) string

func FormatTime

func FormatTime(t time.Time) string

FormatTime 格式化时间为 HH:MM:SS 格式

func RoundFloat

func RoundFloat[T ConvertableToFloat](value T, decimalPlaces int) T

RoundFloat 函数将浮点数四舍五入到指定小数位数

func ToCamelCase

func ToCamelCase(s string) string

ToCamelCase 将字符串转换为 CamelCase

func ToKebabCase

func ToKebabCase(s string) string

ToKebabCase 将字符串转换为 kebab-case

func ToLowerCamelCase

func ToLowerCamelCase(s string) string

ToLowerCamelCase 将字符串转换为 lowerCamelCase

func ToPascalCase

func ToPascalCase(s string) string

ToPascalCase 将字符串转换为 PascalCase(与 UpperCamelCase 相同)

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase 将字符串转换为 snake_case

func ToSpaceCase

func ToSpaceCase(s string) string

ToSpaceCase 将字符串转换为空格分隔

func ToTabCase

func ToTabCase(s string) string

ToTabCase 将字符串转换为制表符分隔

func ToTitleCase

func ToTitleCase(s string) string

ToTitleCase 将字符串转换为 Title Case

func ToUpperCamelCase

func ToUpperCamelCase(s string) string

ToUpperCamelCase 将字符串转换为 UpperCamelCase

func TruncateFloat

func TruncateFloat[T ConvertableToFloat](value T, decimalPlaces int) T

TruncateFloat 函数将浮点数截断到指定小数位数

Types

type ConvertableToFloat

type ConvertableToFloat interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL