cad

package module
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 7 Imported by: 5

README

go-cad

Check Docs HERE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CAD

type CAD struct {
	// contains filtered or unexported fields
}

func Cents

func Cents(n int64) CAD

func ParseCAD

func ParseCAD(s string) (cad CAD, err error)

ParseCAD parses the string ‘s’ and return the equivalent CAD.

If ‘s’ does not contain a money amount, then ParseCAD returns an error.

Some example valid strings include:

• -$1234.56 • $-1234.56 • -$1,234.56 • $-1,234.56 • CAD -$1234.56 • CAD $-1234.56 • CAD-$1,234.56 • CAD$-1,234.56 • $1234.56 • $1,234.56 • CAD $1234.56 • CAD $1,234.56 • CAD$1234.56 • CAD$1,234.56 • $0.09 • $.09 • -$0.09 • -$.09 • $-0.09 • $-.09 • CAD $0.09 • CAD $.09 • CAD -$0.09 • CAD -$.09 • CAD $-0.09 • CAD $-.09 • CAD$0.09 • CAD$.09 • CAD-$0.09 • CAD-$.09 • CAD$-0.09 • CAD$-.09 • 9¢ • -9¢ • 123456¢ • -123456¢

func (CAD) Abs

func (c CAD) Abs() CAD

Abs returns the absolute value.

func (CAD) Add

func (c CAD) Add(other CAD) CAD

Add adds two CAD and returns the result.

func (CAD) AsCents

func (c CAD) AsCents() int64

AsCents returns CAD as the number of pennies it is equivalent to.

func (CAD) CanonicalForm

func (c CAD) CanonicalForm() (dollars int64, cents int64)

CanonicalForm returns the number of dollars and cents that CAD represents.

‘cents’ is always less than for equal to 99. I.e.,:

cents ≤ 99

func (CAD) GoString

func (c CAD) GoString() string

func (CAD) MarshalJSON

func (c CAD) MarshalJSON() (b []byte, err error)

func (CAD) Mul

func (c CAD) Mul(scalar int64) CAD

Mul multiplies CAD by a scalar (number) and returns the result.

func (*CAD) Scan

func (c *CAD) Scan(value interface{}) (err error)

func (CAD) String

func (c CAD) String() string

func (CAD) Sub

func (c CAD) Sub(other CAD) CAD

Sub subtracts two CAD and returns the result.

func (*CAD) UnmarshalJSON

func (c *CAD) UnmarshalJSON(b []byte) (err error)

func (CAD) Value

func (c CAD) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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