Git Product home page Git Product logo

goment's People

Contributors

chuongtrh avatar dimasdanz avatar hexadecy avatar kesyn-duplicate avatar linus-boehm avatar ncox-smartsheet avatar nleeper avatar onchere avatar ptimson avatar smsadegh19 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goment's Issues

Stackoverflow with Tinygo

I was trying to run goment using TinyGo. I get a compile error.
Here is an example to reproduce:


import (
	"fmt"

	"github.com/nleeper/goment"
)

func main() {
	JourAn, _ := goment.New(goment.DateTime{
		Year:  2019,
		Month: 1,
		Day:   1,
	})
	fmt.Printf(JourAn.ToString())
}```


I get this output:


```runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc028400388 stack=[0xc028400000, 0xc048400000]
fatal error: stack overflow

runtime stack:
runtime.throw(0x812bb99, 0xe)
        /usr/local/go/src/runtime/panic.go:1117 +0x72
runtime.newstack()
        /usr/local/go/src/runtime/stack.go:1069 +0x7ed
runtime.morestack()
        /usr/local/go/src/runtime/asm_amd64.s:458 +0x8f

goroutine 13 [running]:
runtime.mapaccess2_fast32(0x80c7520, 0xc009778de0, 0x90c, 0x0, 0x0)
        /usr/local/go/src/runtime/map_fast32.go:52 +0x1b2 fp=0xc028400398 sp=0xc028400390 pc=0x4013792
github.com/tinygo-org/tinygo/interp.(*memoryView).get(0xc009778db0, 0xc00000090c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /Users/distiller/project/interp/memory.go:225 +0xa6 fp=0xc028400460 sp=0xc028400398 pc=0x42e6466
github.com/tinygo-org/tinygo/interp.(*memoryView).get(0xc009812450, 0x90c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /Users/distiller/project/interp/memory.go:229 +0x1b6 fp=0xc028400528 sp=0xc028400460 pc=0x42e6576
github.com/tinygo-org/tinygo/interp.pointerValue.llvmValue(...)
        /Users/distiller/project/interp/memory.go:504
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:512 +0x5b fp=0xc028400668 sp=0xc028400528 pc=0x42e819b
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028400748 sp=0xc028400668 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028400888 sp=0xc028400748 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028400968 sp=0xc028400888 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028400aa8 sp=0xc028400968 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028400b88 sp=0xc028400aa8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028400cc8 sp=0xc028400b88 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028400da8 sp=0xc028400cc8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028400ee8 sp=0xc028400da8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028400fc8 sp=0xc028400ee8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028401108 sp=0xc028400fc8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284011e8 sp=0xc028401108 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028401328 sp=0xc0284011e8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028401408 sp=0xc028401328 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028401548 sp=0xc028401408 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028401628 sp=0xc028401548 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028401768 sp=0xc028401628 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028401848 sp=0xc028401768 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028401988 sp=0xc028401848 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028401a68 sp=0xc028401988 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028401ba8 sp=0xc028401a68 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028401c88 sp=0xc028401ba8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028401dc8 sp=0xc028401c88 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028401ea8 sp=0xc028401dc8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028401fe8 sp=0xc028401ea8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284020c8 sp=0xc028401fe8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028402208 sp=0xc0284020c8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284022e8 sp=0xc028402208 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028402428 sp=0xc0284022e8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028402508 sp=0xc028402428 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028402648 sp=0xc028402508 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028402728 sp=0xc028402648 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028402868 sp=0xc028402728 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028402948 sp=0xc028402868 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028402a88 sp=0xc028402948 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028402b68 sp=0xc028402a88 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028402ca8 sp=0xc028402b68 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028402d88 sp=0xc028402ca8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028402ec8 sp=0xc028402d88 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028402fa8 sp=0xc028402ec8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc0284030e8 sp=0xc028402fa8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284031c8 sp=0xc0284030e8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028403308 sp=0xc0284031c8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284033e8 sp=0xc028403308 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028403528 sp=0xc0284033e8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028403608 sp=0xc028403528 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028403748 sp=0xc028403608 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028403828 sp=0xc028403748 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028403968 sp=0xc028403828 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028403a48 sp=0xc028403968 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028403b88 sp=0xc028403a48 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028403c68 sp=0xc028403b88 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028403da8 sp=0xc028403c68 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028403e88 sp=0xc028403da8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028403fc8 sp=0xc028403e88 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284040a8 sp=0xc028403fc8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc0284041e8 sp=0xc0284040a8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284042c8 sp=0xc0284041e8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028404408 sp=0xc0284042c8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284044e8 sp=0xc028404408 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028404628 sp=0xc0284044e8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028404708 sp=0xc028404628 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028404848 sp=0xc028404708 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028404928 sp=0xc028404848 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028404a68 sp=0xc028404928 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028404b48 sp=0xc028404a68 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028404c88 sp=0xc028404b48 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028404d68 sp=0xc028404c88 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028404ea8 sp=0xc028404d68 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028404f88 sp=0xc028404ea8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc0284050c8 sp=0xc028404f88 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284051a8 sp=0xc0284050c8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc0284052e8 sp=0xc0284051a8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284053c8 sp=0xc0284052e8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028405508 sp=0xc0284053c8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284055e8 sp=0xc028405508 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028405728 sp=0xc0284055e8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028405808 sp=0xc028405728 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028405948 sp=0xc028405808 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028405a28 sp=0xc028405948 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028405b68 sp=0xc028405a28 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028405c48 sp=0xc028405b68 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028405d88 sp=0xc028405c48 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028405e68 sp=0xc028405d88 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028405fa8 sp=0xc028405e68 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028406088 sp=0xc028405fa8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc0284061c8 sp=0xc028406088 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284062a8 sp=0xc0284061c8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc0284063e8 sp=0xc0284062a8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284064c8 sp=0xc0284063e8 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028406608 sp=0xc0284064c8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc0284066e8 sp=0xc028406608 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028406828 sp=0xc0284066e8 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028406908 sp=0xc028406828 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028406a48 sp=0xc028406908 pc=0x42e8845
github.com/tinygo-org/tinygo/interp.rawValue.rawLLVMValue(0xc0097c6000, 0x70, 0x70, 0xc009812450, 0x70)
        /Users/distiller/project/interp/memory.go:1045 +0x16e fp=0xc028406b28 sp=0xc028406a48 pc=0x42eb62e
github.com/tinygo-org/tinygo/interp.pointerValue.toLLVMValue(0x90c00000040, 0x0, 0xc009812450, 0xa61a260)
        /Users/distiller/project/interp/memory.go:521 +0x705 fp=0xc028406c68 sp=0xc028406b28 pc=0x42e8845
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:73 +0xc5

goroutine 1 [chan receive]:
github.com/tinygo-org/tinygo/builder.runJobs(0xc002c27180, 0x4, 0x4, 0x0, 0x0)
        /Users/distiller/project/builder/jobs.go:105 +0x12e
github.com/tinygo-org/tinygo/builder.Build(0x7ffeefbffa53, 0x12, 0x8126f1d, 0x4, 0xc0001efe30, 0xc002bc1ba0, 0x0, 0x0)
        /Users/distiller/project/builder/build.go:327 +0x191d
main.Run(0x7ffeefbffa53, 0x12, 0xc0002b2000, 0xe, 0x0)
        /Users/distiller/project/main.go:519 +0xb2
main.main()
        /Users/distiller/project/main.go:986 +0x213b

goroutine 6 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc001093140, 0xc001092a80)
        /Users/distiller/project/builder/jobs.go:151 +0x91
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:73 +0xc5

goroutine 7 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc001093140, 0xc001092a80)
        /Users/distiller/project/builder/jobs.go:151 +0x91
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:73 +0xc5

goroutine 8 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc001093140, 0xc001092a80)
        /Users/distiller/project/builder/jobs.go:151 +0x91
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:73 +0xc5

goroutine 9 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc001093140, 0xc001092a80)
        /Users/distiller/project/builder/jobs.go:151 +0x91
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:73 +0xc5

goroutine 10 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc001093140, 0xc001092a80)
        /Users/distiller/project/builder/jobs.go:151 +0x91
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:73 +0xc5

goroutine 11 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc001093140, 0xc001092a80)
        /Users/distiller/project/builder/jobs.go:151 +0x91
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:73 +0xc5

goroutine 12 [chan receive]:
github.com/tinygo-org/tinygo/builder.jobWorker(0xc001093140, 0xc001092a80)
        /Users/distiller/project/builder/jobs.go:151 +0x91
created by github.com/tinygo-org/tinygo/builder.runJobs
        /Users/distiller/project/builder/jobs.go:73 +0xc5```

isoWeek

date, _ := goment.New()

	lastWeekStart := date.StartOf("isoWeek").Format("YYYY-MM-DD HH:MM:ss")
	lastWeekEnd := date.EndOf("isoWeek").Format("YYYY-MM-DD HH:MM:ss")
	fmt.Println(lastWeekStart)
	fmt.Println(lastWeekEnd)

output

2022-10-17 00:10:00 ❌
2022-10-23 23:10:59 ❌

2022-10-17 00:00:00 
2022-10-23 23:59:59

Date arithmetic error

When adding time to dates, there is not parity when using the Diff function.

package main

import (
	"fmt"
	"github.com/nleeper/goment"
	"time"
)

const TIME_ZONE = "America/Los_Angeles"

func main() {
	// SetLocale to ensure local specific names, start of week, etc
	goment.SetLocale("en")

	// Set timezone to be used
	loc, err := time.LoadLocation(TIME_ZONE)
	if err != nil {
		fmt.Println(err)
	}

	dt, err := time.ParseInLocation(time.RFC1123, "Tue, 04 Jan 2022 16:00:00 PST", loc)
	if err != nil {
		fmt.Println(err)
	}

	gdt, err := goment.New(dt)
	if err != nil {
		fmt.Println(err)
	}

	fmt.Println("Start date:" + gdt.ToString())

	for i := 2; i != 20; i += 2 {
		t := gdt.Clone().Add(i, "weeks")
		delta := t.Diff(gdt, "weeks")
		fmt.Printf("Date: %s, Interval: %d, Delta: %d\n", t.ToString(), i, delta)
	}
}

Outputs:
Start date: 2022-01-04 16:00:00 -0800 PST
Date: 2022-01-18 16:00:00 -0800 PST, Interval: 2, Delta: 2
Date: 2022-02-01 16:00:00 -0800 PST, Interval: 4, Delta: 4
Date: 2022-02-15 16:00:00 -0800 PST, Interval: 6, Delta: 6
Date: 2022-03-01 16:00:00 -0800 PST, Interval: 8, Delta: 8
Date: 2022-03-15 16:00:00 -0700 PDT, Interval: 10, Delta: 9
Date: 2022-03-29 16:00:00 -0700 PDT, Interval: 12, Delta: 11
Date: 2022-04-12 16:00:00 -0700 PDT, Interval: 14, Delta: 13
Date: 2022-04-26 16:00:00 -0700 PDT, Interval: 16, Delta: 15
Date: 2022-05-10 16:00:00 -0700 PDT, Interval: 18, Delta: 17

Notice the "delta", the result of diff, show 9 weeks despite 10 being added.

StartOf("isoWeek") not correct on Sunday

now, _ := goment.New("2021-04-11")
fmt.Println(now.Format("YYYYMMDD"))
//output: 20210411
now.StartOf("isoWeek")
fmt.Println(now.Format("YYYYMMDD"))
//output: 20210412, should be 20210405

IsSame() and similar functions

Could you please update the documentation for IsSame() and its similar functions?

I noticed that this will not always return the correct result:

// d1 and d2 are both of type goment.Goment
d1.IsSameOrBefore(d2)

In order to fix this, I had to use this instead:

d1.IsSameOrBefore(&d1)

In the first example, false could be returned when true should be returned because of this section of code:

switch v := args[0].(type) {

This switch statement never checks for type Goment -- only for type *Goment. Therefore, false is returned without comparing the dates.

In addition to updating the documentation, you could have the switch statement also check for a Goment type.

go get -v github.com/nleeper/goment error

Tried doing go get -v github.com/nleeper/goment

Expected Behaviour

Install successfully

Error

../../pkg/mod/github.com/nleeper/[email protected]/goment.go:7:2: module github.com/nleeper/goment@latest found (v1.0.8), but does not contain package github.com/nleeper/goment/internal/locales

Format() does not support both long and abbreviated form of time zone

I was usingFormat to print the time zone information. I was expecting the abbreviated form but got the long form. I tried both "z" and "zz" with the same result.

What was done:

g, _ := goment.Unix(time.Now().Unix())
fmt.Println(g.Format("zz"))
fmt.Println(g.Format("z"))

Output expected:
"Eastern Daylight Time"
"EST"

What happened:
"Eastern Daylight Time"
"Eastern Daylight Time"

Date interval calculation logic is incorrect

func (d diff) InDays() int { return absFloor(math.Floor(float64(d.InHours()) / 24)) }

this method should return absFloor(float64(d.InHours()) / 24) 。
When the value of float64(d.InHours()) / 24 is negative, math.Floor() will calculate the nearest negative integer but less than float64(d.InHours()) / 24, the absFloor is meaningless

Document making sure int are passed to the library

Hello 👋 ,
not a bug per-se, but something that is not explicitly said: you are expecting amounts to be expressed in int. Not int32, not int64 but plain int. https://github.com/nleeper/goment/blob/main/add_subtract.go#L13 😅

I was pulling my hair not understanding why the library was not subtracting 15min to my object. Turns out I was using .ParseInt to get my amount, and it returns... an int64.

Time does not change:

input := "now-15min"
// ...
moment, _ := goment.New() // 2021-08-05 18:22:32.422501853 +0000 UTC
// ...
num, _ := strconv.ParseInt(input[i:j], 10, 64) // num = 15
// ...
unit := string(input[i]) // unit = "m"

log.Printf("Subtracting %d%s", num, unit) // Subtracting 15m
moment.Subtract(num, unit) // 2021-08-05 18:22:32.422501853 +0000 UTC <- Unchanged

Time changes:

input := "now-15min"
// ...
moment, _ := goment.New() // 2021-08-05 18:33:02.429106516 +0000 UTC
// ...
num, _ := strconv.ParseInt(input[i:j], 10, 64) // num = 15
// ...
unit := string(input[i]) // unit = "m"

log.Printf("Subtracting %d%s", num, unit) // Subtracting 15m
moment.Subtract(int(num), unit) // 2021-08-05 18:18:02.429106516 +0000 UTC <- Changed

Hopefully this helps anyone in my situation 😁

concurrent map writes

fatal error: concurrent map writes

goroutine 429 [running]:
github.com/nleeper/goment.addParseReplacement({0xc0007cc970?, 0x2?, 0x2?})
/Users/lee/go/pkg/mod/github.com/nleeper/[email protected]/parse.go:258 +0x18a
github.com/nleeper/goment.loadParseReplacements()
/Users/lee/go/pkg/mod/github.com/nleeper/[email protected]/parse.go:116 +0x151
github.com/nleeper/goment.New({0xc0007cd248, 0x1, 0xc000382ff0?})
/Users/lee/go/pkg/mod/github.com/nleeper/[email protected]/goment.go:32 +0x3e

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.