Skip to content

Empty string is not consistent #311

@a8ss

Description

@a8ss

Hello,

I encountered an issue with the following code:

func TestCabon2(t *testing.T) {
	j := []byte(`{"c":""}`)
	d := struct {
		C carbon.Carbon `json:"c"`
	}{}
	err := json.Unmarshal(j, &d)
	fmt.Printf("IsValid: %v, IsZero: %v, IsEmpty: %v, HasError: %v, err: %v\n", d.C.IsValid(), d.C.IsZero(), d.C.IsEmpty(), d.C.HasError(), err)

	c := carbon.Parse("")
	fmt.Printf("IsValid: %v, IsZero: %v, IsEmpty: %v, HasError: %v\n", c.IsValid(), c.IsZero(), c.IsEmpty(), c.HasError())
}

golang version: such as v1.23

carbon version: such as 2.5.12, 2.6.11

time zone: such as Japan

I expected to get:

IsValid: false, IsZero: false, IsEmpty: true, HasError: false

But I actually get:

IsValid: true, IsZero: true, IsEmpty: false, HasError: false, err: <nil>

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReport a reproducible bug or regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions