[go] time: add DateTime, DateOnly, and TimeOnly

165 views
Skip to first unread message

Joseph Tsai (Gerrit)

unread,
Jun 15, 2022, 4:07:42 PM6/15/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Joseph Tsai has uploaded this change for review.

View Change

time: add DateTime, DateOnly, and TimeOnly

Add named constants for the 3rd, 4th, and 13th most popular formats.

Fixes #52746

Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
---
M src/time/format.go
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/time/format.go b/src/time/format.go
index 5f69618..f7cdade 100644
--- a/src/time/format.go
+++ b/src/time/format.go
@@ -116,6 +116,9 @@
StampMilli = "Jan _2 15:04:05.000"
StampMicro = "Jan _2 15:04:05.000000"
StampNano = "Jan _2 15:04:05.000000000"
+ DateTime = "2006-01-02 15:04:05"
+ DateOnly = "2006-01-02"
+ TimeOnly = "15:04:05"
)

const (

To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
Gerrit-Change-Number: 412495
Gerrit-PatchSet: 1
Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
Gerrit-MessageType: newchange

Joseph Tsai (Gerrit)

unread,
Jun 15, 2022, 4:11:17 PM6/15/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Joseph Tsai uploaded patch set #2 to this change.

View Change

time: add DateTime, DateOnly, and TimeOnly

Add named constants for the 3rd, 4th, and 13th most popular formats.

Fixes #52746

Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
---
M src/time/format.go
M src/time/format_test.go
2 files changed, 19 insertions(+), 0 deletions(-)

To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
Gerrit-Change-Number: 412495
Gerrit-PatchSet: 2
Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
Gerrit-MessageType: newpatchset

Joseph Tsai (Gerrit)

unread,
Jun 15, 2022, 4:13:37 PM6/15/22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Patch set 2:Run-TryBot +1Auto-Submit +1

View Change

    To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
    Gerrit-Change-Number: 412495
    Gerrit-PatchSet: 2
    Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Comment-Date: Wed, 15 Jun 2022 20:13:32 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Joseph Tsai (Gerrit)

    unread,
    Jun 15, 2022, 4:18:12 PM6/15/22
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Attention is currently required from: Joseph Tsai.

    Joseph Tsai uploaded patch set #3 to this change.

    View Change

    The following approvals got outdated and were removed: Auto-Submit+1 by Joseph Tsai, Run-TryBot+1 by Joseph Tsai

    time: add DateTime, DateOnly, and TimeOnly

    Add named constants for the 3rd, 4th, and 13th most popular formats.

    Fixes #52746

    Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
    ---
    A api/next/52746.txt
    M src/time/format.go
    M src/time/format_test.go
    3 files changed, 22 insertions(+), 0 deletions(-)

    To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
    Gerrit-Change-Number: 412495
    Gerrit-PatchSet: 3
    Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
    Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
    Gerrit-MessageType: newpatchset

    Joseph Tsai (Gerrit)

    unread,
    Jun 15, 2022, 4:18:32 PM6/15/22
    to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

    Patch set 3:Run-TryBot +1Auto-Submit +1

    View Change

      To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
      Gerrit-Change-Number: 412495
      Gerrit-PatchSet: 3
      Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
      Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-Comment-Date: Wed, 15 Jun 2022 20:18:28 +0000

      Joseph Tsai (Gerrit)

      unread,
      Aug 8, 2022, 1:48:29 PM8/8/22
      to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

      Patch set 4:Run-TryBot +1Auto-Submit +1

      View Change

        To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
        Gerrit-Change-Number: 412495
        Gerrit-PatchSet: 4
        Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Comment-Date: Mon, 08 Aug 2022 17:48:24 +0000

        Ian Lance Taylor (Gerrit)

        unread,
        Aug 8, 2022, 3:52:43 PM8/8/22
        to Joseph Tsai, goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

        Attention is currently required from: Joseph Tsai.

        View Change

        1 comment:

        • File api/next/52746.txt:

          • Patch Set #4, Line 1: pkg time, const DateOnly = "2006-01-02"

            The format is

            pkg time, const DateOnly = "2006-01-02" #52746

            That is, you are missing the proposal number at the end of the line. It's not currently taken from the file name.

        To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
        Gerrit-Change-Number: 412495
        Gerrit-PatchSet: 4
        Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
        Gerrit-CC: Ian Lance Taylor <ia...@google.com>
        Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Comment-Date: Mon, 08 Aug 2022 19:52:39 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        Gerrit-MessageType: comment

        Joseph Tsai (Gerrit)

        unread,
        Aug 8, 2022, 4:22:01 PM8/8/22
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

        Attention is currently required from: Joseph Tsai.

        Joseph Tsai uploaded patch set #5 to this change.

        View Change

        The following approvals got outdated and were removed: Auto-Submit+1 by Joseph Tsai, Run-TryBot+1 by Joseph Tsai, TryBot-Result-1 by Gopher Robot

        time: add DateTime, DateOnly, and TimeOnly

        Add named constants for the 3rd, 4th, and 13th most popular formats.

        Fixes #52746

        Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
        ---
        A api/next/52746.txt
        M src/time/format.go
        M src/time/format_test.go
        3 files changed, 22 insertions(+), 0 deletions(-)

        To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
        Gerrit-Change-Number: 412495
        Gerrit-PatchSet: 5
        Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
        Gerrit-CC: Ian Lance Taylor <ia...@google.com>
        Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
        Gerrit-MessageType: newpatchset

        Joseph Tsai (Gerrit)

        unread,
        Aug 8, 2022, 4:22:27 PM8/8/22
        to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

        Attention is currently required from: Ian Lance Taylor.

        Patch set 5:Run-TryBot +1Auto-Submit +1

        View Change

        1 comment:

        • File api/next/52746.txt:

          • The format is […]

            Ah, thank you.

        To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
        Gerrit-Change-Number: 412495
        Gerrit-PatchSet: 5
        Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
        Gerrit-CC: Ian Lance Taylor <ia...@google.com>
        Gerrit-Attention: Ian Lance Taylor <ia...@google.com>
        Gerrit-Comment-Date: Mon, 08 Aug 2022 20:22:23 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Comment-In-Reply-To: Ian Lance Taylor <ia...@google.com>
        Gerrit-MessageType: comment

        Ian Lance Taylor (Gerrit)

        unread,
        Aug 8, 2022, 4:39:35 PM8/8/22
        to Joseph Tsai, goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

        Attention is currently required from: Joseph Tsai.

        Patch set 5:Code-Review +2

        View Change

        1 comment:

        To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
        Gerrit-Change-Number: 412495
        Gerrit-PatchSet: 5
        Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
        Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Comment-Date: Mon, 08 Aug 2022 20:39:31 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: Yes
        Gerrit-MessageType: comment

        Joseph Tsai (Gerrit)

        unread,
        Aug 8, 2022, 5:22:48 PM8/8/22
        to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

        Attention is currently required from: Joseph Tsai.

        Joseph Tsai uploaded patch set #6 to this change.

        View Change

        The following approvals got outdated and were removed: Auto-Submit+1 by Joseph Tsai, Run-TryBot+1 by Joseph Tsai, TryBot-Result-1 by Gopher Robot

        time: add DateTime, DateOnly, and TimeOnly

        Add named constants for the 3rd, 4th, and 13th most popular formats.

        Fixes #52746

        Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
        ---
        A api/next/52746.txt
        M src/time/format.go
        M src/time/format_test.go
        3 files changed, 25 insertions(+), 0 deletions(-)

        To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: go
        Gerrit-Branch: master
        Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
        Gerrit-Change-Number: 412495
        Gerrit-PatchSet: 6
        Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Reviewer: Gopher Robot <go...@golang.org>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
        Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
        Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
        Gerrit-MessageType: newpatchset

        Joseph Tsai (Gerrit)

        unread,
        Aug 8, 2022, 5:23:17 PM8/8/22
        to goph...@pubsubhelper.golang.org, Gopher Robot, golang-co...@googlegroups.com

        Patch set 6:Run-TryBot +1Auto-Submit +1

        View Change

          To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: go
          Gerrit-Branch: master
          Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
          Gerrit-Change-Number: 412495
          Gerrit-PatchSet: 6
          Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
          Gerrit-Reviewer: Gopher Robot <go...@golang.org>
          Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
          Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
          Gerrit-Comment-Date: Mon, 08 Aug 2022 21:23:13 +0000

          Dmitri Shuralyov (Gerrit)

          unread,
          Aug 9, 2022, 10:33:03 AM8/9/22
          to Joseph Tsai, goph...@pubsubhelper.golang.org, Dmitri Shuralyov, Gopher Robot, golang-co...@googlegroups.com

          Attention is currently required from: Joseph Tsai.

          Patch set 6:Code-Review +1

          View Change

            To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
            Gerrit-Change-Number: 412495
            Gerrit-PatchSet: 6
            Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
            Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
            Gerrit-Reviewer: Gopher Robot <go...@golang.org>
            Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
            Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
            Gerrit-CC: Dmitri Shuralyov <dmit...@golang.org>
            Gerrit-Attention: Joseph Tsai <joe...@digital-static.net>
            Gerrit-Comment-Date: Tue, 09 Aug 2022 14:32:58 +0000

            Gopher Robot (Gerrit)

            unread,
            Aug 9, 2022, 10:33:28 AM8/9/22
            to Joseph Tsai, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Dmitri Shuralyov, Dmitri Shuralyov, golang-co...@googlegroups.com

            Gopher Robot submitted this change.

            View Change



            5 is the latest approved patch-set.
            The change was submitted with unreviewed changes in the following files:

            ```
            The name of the file: api/next/52746.txt
            Insertions: 3, Deletions: 0.

            @@ -1,3 +1,6 @@
            pkg time, const DateOnly = "2006-01-02" #52746
            +pkg time, const DateOnly ideal-string #52746
            pkg time, const DateTime = "2006-01-02 15:04:05" #52746
            +pkg time, const DateTime ideal-string #52746
            pkg time, const TimeOnly = "15:04:05" #52746
            +pkg time, const TimeOnly ideal-string #52746
            ```

            Approvals: Dmitri Shuralyov: Looks good to me, but someone else must approve Joseph Tsai: Run TryBots; Automatically submit change Gopher Robot: TryBots succeeded Ian Lance Taylor: Looks good to me, approved
            time: add DateTime, DateOnly, and TimeOnly

            Add named constants for the 3rd, 4th, and 13th most popular formats.

            Fixes #52746

            Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
            Reviewed-on: https://go-review.googlesource.com/c/go/+/412495
            Reviewed-by: Ian Lance Taylor <ia...@google.com>
            Auto-Submit: Joseph Tsai <joe...@digital-static.net>
            Reviewed-by: Dmitri Shuralyov <dmit...@google.com>
            TryBot-Result: Gopher Robot <go...@golang.org>
            Run-TryBot: Joseph Tsai <joe...@digital-static.net>

            ---
            A api/next/52746.txt
            M src/time/format.go
            M src/time/format_test.go
            3 files changed, 31 insertions(+), 0 deletions(-)

            diff --git a/api/next/52746.txt b/api/next/52746.txt
            new file mode 100644
            index 0000000..d6c3bd2
            --- /dev/null
            +++ b/api/next/52746.txt
            @@ -0,0 +1,6 @@
            +pkg time, const DateOnly = "2006-01-02" #52746
            +pkg time, const DateOnly ideal-string #52746
            +pkg time, const DateTime = "2006-01-02 15:04:05" #52746
            +pkg time, const DateTime ideal-string #52746
            +pkg time, const TimeOnly = "15:04:05" #52746
            +pkg time, const TimeOnly ideal-string #52746
            diff --git a/src/time/format.go b/src/time/format.go
            index 8431ff8..61a9eb3 100644

            --- a/src/time/format.go
            +++ b/src/time/format.go
            @@ -116,6 +116,9 @@
            StampMilli = "Jan _2 15:04:05.000"
            StampMicro = "Jan _2 15:04:05.000000"
            StampNano = "Jan _2 15:04:05.000000000"
            + DateTime = "2006-01-02 15:04:05"
            + DateOnly = "2006-01-02"
            + TimeOnly = "15:04:05"
            )

            const (
            diff --git a/src/time/format_test.go b/src/time/format_test.go
            index 9ae2b80..fa8c846 100644
            --- a/src/time/format_test.go
            +++ b/src/time/format_test.go
            @@ -115,6 +115,9 @@
            {"StampMilli", StampMilli, "Feb 4 21:00:57.012"},
            {"StampMicro", StampMicro, "Feb 4 21:00:57.012345"},
            {"StampNano", StampNano, "Feb 4 21:00:57.012345600"},
            + {"DateTime", DateTime, "2009-02-04 21:00:57"},
            + {"DateOnly", DateOnly, "2009-02-04"},
            + {"TimeOnly", TimeOnly, "21:00:57"},
            {"YearDay", "Jan 2 002 __2 2", "Feb 4 035 35 4"},
            {"Year", "2006 6 06 _6 __6 ___6", "2009 6 09 _6 __6 ___6"},
            {"Month", "Jan January 1 01 _1", "Feb February 2 02 _2"},

            To view, visit change 412495. To unsubscribe, or for help writing mail filters, visit settings.

            Gerrit-Project: go
            Gerrit-Branch: master
            Gerrit-Change-Id: I7ce92e44dcae18c089124f1d6f5bc2d6359d436c
            Gerrit-Change-Number: 412495
            Gerrit-PatchSet: 7
            Gerrit-Owner: Joseph Tsai <joe...@digital-static.net>
            Gerrit-Reviewer: Dmitri Shuralyov <dmit...@google.com>
            Gerrit-Reviewer: Gopher Robot <go...@golang.org>
            Gerrit-Reviewer: Ian Lance Taylor <ia...@google.com>
            Gerrit-Reviewer: Joseph Tsai <joe...@digital-static.net>
            Gerrit-CC: Dmitri Shuralyov <dmit...@golang.org>
            Gerrit-MessageType: merged
            Reply all
            Reply to author
            Forward
            0 new messages