Now is a time toolkit for golang

Now

Now is a time toolkit for golang

wercker status

Install

go get -u github.com/jinzhu/now

Usage

Calculating time based on current time

import "github.com/jinzhu/now"

time.Now() // 2013-11-18 17:51:49.123456789 Mon

now.BeginningOfMinute()        // 2013-11-18 17:51:00 Mon
now.BeginningOfHour()          // 2013-11-18 17:00:00 Mon
now.BeginningOfDay()           // 2013-11-18 00:00:00 Mon
now.BeginningOfWeek()          // 2013-11-17 00:00:00 Sun
now.BeginningOfMonth()         // 2013-11-01 00:00:00 Fri
now.BeginningOfQuarter()       // 2013-10-01 00:00:00 Tue
now.BeginningOfYear()          // 2013-01-01 00:00:00 Tue

now.WeekStartDay = time.Monday // Set Monday as first day, default is Sunday
now.BeginningOfWeek()          // 2013-11-18 00:00:00 Mon

now.EndOfMinute()              // 2013-11-18 17:51:59.999999999 Mon
now.EndOfHour()                // 2013-11-18 17:59:59.999999999 Mon
now.EndOfDay()                 // 2013-11-18 23:59:59.999999999 Mon
now.EndOfWeek()                // 2013-11-23 23:59:59.999999999 Sat
now.EndOfMonth()               // 2013-11-30 23:59:59.999999999 Sat
now.EndOfQuarter()             // 2013-12-31 23:59:59.999999999 Tue
now.EndOfYear()                // 2013-12-31 23:59:59.999999999 Tue

now.WeekStartDay = time.Monday // Set Monday as first day, default is Sunday
now.EndOfWeek()                // 2013-11-24 23:59:59.999999999 Sun

Calculating time based on another time

t := time.Date(2013, 02, 18, 17, 51, 49, 123456789, time.Now().Location())
now.With(t).EndOfMonth()   // 2013-02-28 23:59:59.999999999 Thu

Calculating time based on configuration

location, err := time.LoadLocation("Asia/Shanghai")

myConfig := &now.Config{
	WeekStartDay: time.Monday,
	TimeLocation: location,
	TimeFormats: []string{"2006-01-02 15:04:05"},
}

t := time.Date(2013, 11, 18, 17, 51, 49, 123456789, time.Now().Location()) // // 2013-11-18 17:51:49.123456789 Mon
myConfig.With(t).BeginningOfWeek()         // 2013-11-18 00:00:00 Mon

myConfig.Parse("2002-10-12 22:14:01")     // 2002-10-12 22:14:01
myConfig.Parse("2002-10-12 22:14")        // returns error 'can't parse string as time: 2002-10-12 22:14'

Monday/Sunday

Don't be bothered with the WeekStartDay setting, you can use Monday, Sunday

now.Monday()              // 2013-11-18 00:00:00 Mon
now.Sunday()              // 2013-11-24 00:00:00 Sun (Next Sunday)
now.EndOfSunday()         // 2013-11-24 23:59:59.999999999 Sun (End of next Sunday)

t := time.Date(2013, 11, 24, 17, 51, 49, 123456789, time.Now().Location()) // 2013-11-24 17:51:49.123456789 Sun
now.With(t).Monday()       // 2013-11-18 00:00:00 Sun (Last Monday if today is Sunday)
now.With(t).Sunday()       // 2013-11-24 00:00:00 Sun (Beginning Of Today if today is Sunday)
now.With(t).EndOfSunday()  // 2013-11-24 23:59:59.999999999 Sun (End of Today if today is Sunday)

Parse String to Time

time.Now() // 2013-11-18 17:51:49.123456789 Mon

// Parse(string) (time.Time, error)
t, err := now.Parse("2017")                // 2017-01-01 00:00:00, nil
t, err := now.Parse("2017-10")             // 2017-10-01 00:00:00, nil
t, err := now.Parse("2017-10-13")          // 2017-10-13 00:00:00, nil
t, err := now.Parse("1999-12-12 12")       // 1999-12-12 12:00:00, nil
t, err := now.Parse("1999-12-12 12:20")    // 1999-12-12 12:20:00, nil
t, err := now.Parse("1999-12-12 12:20:21") // 1999-12-12 12:20:00, nil
t, err := now.Parse("10-13")               // 2013-10-13 00:00:00, nil
t, err := now.Parse("12:20")               // 2013-11-18 12:20:00, nil
t, err := now.Parse("12:20:13")            // 2013-11-18 12:20:13, nil
t, err := now.Parse("14")                  // 2013-11-18 14:00:00, nil
t, err := now.Parse("99:99")               // 2013-11-18 12:20:00, Can't parse string as time: 99:99

// MustParse must parse string to time or it will panic
now.MustParse("2013-01-13")             // 2013-01-13 00:00:00
now.MustParse("02-17")                  // 2013-02-17 00:00:00
now.MustParse("2-17")                   // 2013-02-17 00:00:00
now.MustParse("8")                      // 2013-11-18 08:00:00
now.MustParse("2002-10-12 22:14")       // 2002-10-12 22:14:00
now.MustParse("99:99")                  // panic: Can't parse string as time: 99:99

Extend now to support more formats is quite easy, just update now.TimeFormats with other time layouts, e.g:

now.TimeFormats = append(now.TimeFormats, "02 Jan 2006 15:04")

Please send me pull requests if you want a format to be supported officially

Contributing

You can help to make the project better, check out http://gorm.io/contribute.html for things you can do.

Author

jinzhu

License

Released under the MIT License.

Owner
Jinzhu
Life is Art
Jinzhu
Comments
  • now doesn't account for DST

    now doesn't account for DST

    Hey,

    I'm in central Europe, and we currently still have daylight saving time (timezone CEST instead of CET). now doesn't seem to account for the extra hour, so now.BeginningOfYear() currently returns 2014-12-31 23:00:00 +0100 CET instead of midnight.

    Greets, Bobselp

  • Beginning/End of Next Month/Year/...

    Beginning/End of Next Month/Year/...

    i'm a golang beginner used to rails awesome date-helpers that allow you do stuff like 1.month.ago or 3.month.from_now.

    in the same sense, i would like to calculate the timestamp of next month. i could not really find a great way to implement this in golang. maybe i just don't know the right tools though. calculating it by hand is simple but has a lot of edge cases, so i would like to use it from within a library.

    any feedback appreciated.

  • (Question) Why don't just use Truncate for BeginningOfDay()

    (Question) Why don't just use Truncate for BeginningOfDay()

    I was trying to understand your BeginninfOfDay() code: https://github.com/jinzhu/now/blob/master/now.go#L17

    And I was wandering why don't you just use Truncate: t.Truncate(24 * time.Hour)

  • between

    between

    Hi! I found that in the standard library "time", method Between(for checking is target time between first time and second) is missed, however, probably I was inattentive. Anyway, i just implemented it:

    t := time.Date(2015, 06, 30, 17, 51, 49, 123456789, time.Now().Location())
    fmt.Println(now.New(t).Between("2015-05-12 12:20", "2017-12-12 12:20"))
    //=> true
    

    Under the hood of this, is MustParse method, so input can gets any time format.

  • WeekStartDay as an attribute of Now type

    WeekStartDay as an attribute of Now type

    When using the library we could have different scenarios where the WeekStartDay have different values. To avoid concurrence I suggest having a WeekStartDay attribute in the Now type instead of using as a global variable. For backward compatibility we could keep the global variable as a fallback if the new attribute is not defined.

    // WeekStartDay set week start day, default is sunday
    var WeekStartDay = time.Sunday
    
    // Now now struct
    type Now struct {
    	time.Time
    	WeekStartDay *time.Weekday
    }
    
    // BeginningOfWeek beginning of week
    func (now *Now) BeginningOfWeek() time.Time {
    	t := now.BeginningOfDay()
    	weekday := int(t.Weekday())
    
    	weekStartDay := WeekStartDay
    	if now.WeekStartDay != nil {
    		weekStartDay = *now.WeekStartDay
    	}
    
    	if weekStartDay != time.Sunday {
    		weekStartDayInt := int(weekStartDay)
    
    		if weekday < weekStartDayInt {
    			weekday = weekday + 7 - weekStartDayInt
    		} else {
    			weekday = weekday - weekStartDayInt
    		}
    	}
    	return t.AddDate(0, 0, -weekday)
    }
    

    I could work on a PR if you think this is acceptable.

    🤔 The downside is that the type Now wouldn't be easy convertible to time.Time anymore. And this could break some backward compatibility:

    n := now.New(time.Now())
    // ...
    t1 := time.Time(n) // <-- this will fail now
    t2 := n.Time // <-- this will continue working
    
  • Broken when clocks go back

    Broken when clocks go back

    This case does not return the correct data:

    package main
    
    import (
    	"fmt"
    	"time"
    
    	"github.com/jinzhu/now"
    )
    
    func main() {
    	l, _ := time.LoadLocation("Europe/London")
    	t1, _ := time.ParseInLocation(time.RFC3339, "2018-10-28T01:30:00+01:00", l)
    	t2, _ := time.ParseInLocation(time.RFC3339, "2018-10-28T01:30:00Z", l)
    
    	fmt.Println(t1)
    	fmt.Println(t2)
    
    	c1 := now.New(t1).BeginningOfHour()
    	c2 := now.New(t2).BeginningOfHour()
    
    	fmt.Println(c1)
    	fmt.Println(c2)
    }
    

    Actual output:

    2018-10-28 01:30:00 +0100 BST
    2018-10-28 01:30:00 +0000 UTC
    2018-10-28 01:00:00 +0000 GMT
    2018-10-28 01:00:00 +0000 UTC
    

    Expected output:

    2018-10-28 01:30:00 +0100 BST
    2018-10-28 01:30:00 +0000 UTC
    2018-10-28 01:00:00 +0100 BST
    2018-10-28 01:00:00 +0000 UTC
    

    I imagine quite a lot of cases would be affected by the very same problem. The key issue is that time.Date is never safe to use, as its behaviour on ambiguous times (where more than one offset could apply) is undefined.

  • Add MonthAgo and MonthSince

    Add MonthAgo and MonthSince

    When acquiring the past or future time based on the month, time.AddDate does not return the expected value. So, I propose a method that behaves similarly to ActiveSuppot (Rails) 's .months_ago and .months_since.

  • [bug] incorrectly fill up hour with current hour

    [bug] incorrectly fill up hour with current hour

    reproduce test case as below:

    if New(n).MustParse("2002-10-12 00:14:56").Format(format) != "2002-10-12 00:14:56" { t.Errorf("Parse 2002-10-12 00:14:56") }

    parse output is: 2002-10-12 {current hour}:14:56

  • Bump actions/setup-go from 2 to 3

    Bump actions/setup-go from 2 to 3

    Bumps actions/setup-go from 2 to 3.

    Release notes

    Sourced from actions/setup-go's releases.

    v3.0.0

    What's Changed

    Breaking Changes

    With the update to Node 16, all scripts will now be run with Node 16 rather than Node 12.

    This new major release removes the stable input, so there is no need to specify additional input to use pre-release versions. This release also corrects the pre-release versions syntax to satisfy the SemVer notation (1.18.0-beta1 -> 1.18.0-beta.1, 1.18.0-rc1 -> 1.18.0-rc.1).

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v3
        with:
          go-version: '1.18.0-rc.1' 
      - run: go version
    

    Add check-latest input

    In scope of this release we add the check-latest input. If check-latest is set to true, the action first checks if the cached version is the latest one. If the locally cached version is not the most up-to-date, a Go version will then be downloaded from go-versions repository. By default check-latest is set to false. Example of usage:

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-go@v2
        with:
          go-version: '1.16'
          check-latest: true
      - run: go version
    

    Moreover, we updated @actions/core from 1.2.6 to 1.6.0

    v2.1.5

    In scope of this release we updated matchers.json to improve the problem matcher pattern. For more information please refer to this pull request

    v2.1.4

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/setup-go/compare/v2.1.3...v2.1.4

    v2.1.3

    • Updated communication with runner to use environment files rather then workflow commands

    v2.1.2

    This release includes vendored licenses for this action's npm dependencies.

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump actions/cache from 2 to 3.0.1

    Bump actions/cache from 2 to 3.0.1

    Bumps actions/cache from 2 to 3.0.1.

    Release notes

    Sourced from actions/cache's releases.

    v3.0.1

    • Added support for caching from GHES 3.5.
    • Fixed download issue for files > 2GB during restore.

    v3.0.0

    • This change adds a minimum runner version(node12 -> node16), which can break users using an out-of-date/fork of the runner. This would be most commonly affecting users on GHES 3.3 or before, as those runners do not support node16 actions and they can use actions from github.com via github connect or manually copying the repo to their GHES instance.

    • Few dependencies and cache action usage examples have also been updated.

    v2.1.7

    Support 10GB cache upload using the latest version 1.0.8 of @actions/cache

    v2.1.6

    • Catch unhandled "bad file descriptor" errors that sometimes occurs when the cache server returns non-successful response (actions/cache#596)

    v2.1.5

    • Fix permissions error seen when extracting caches with GNU tar that were previously created using BSD tar (actions/cache#527)

    v2.1.4

    • Make caching more verbose #650
    • Use GNU tar on macOS if available #701

    v2.1.3

    • Upgrades @actions/core to v1.2.6 for CVE-2020-15228. This action was not using the affected methods.
    • Fix error handling in uploadChunk where 400-level errors were not being detected and handled correctly

    v2.1.2

    • Adds input to limit the chunk upload size, useful for self-hosted runners with slower upload speeds
    • No-op when executing on GHES

    v2.1.1

    • Update @actions/cache package to v1.0.2 which allows cache action to use posix format when taring files.

    v2.1.0

    • Replaces the http-client with the Azure Storage SDK for NodeJS when downloading cache content from Azure. This should help improve download performance and reliability as the SDK downloads files in 4 MB chunks, which can be parallelized and retried independently
    • Display download progress and speed
    Changelog

    Sourced from actions/cache's changelog.

    3.0.1

    • Added support for caching from GHES 3.5.
    • Fixed download issue for files > 2GB during restore.
    Commits
    • 136d96b Enabling actions/cache for GHES based on presence of AC service (#774)
    • 7d4f40b Bumping up the version to fix download issue for files > 2 GB. (#775)
    • 2d8d0d1 Updated what's new. (#771)
    • 7799d86 Updated the usage and docs to the major version release. (#770)
    • 4b0cf6c Merge pull request #769 from actions/users/ashwinsangem/bump_major_version
    • 60c606a Update licensed files
    • b6e9a91 Revert "Updated to the latest version."
    • c842503 Updated to the latest version.
    • 2b7da2a Bumped up to a major version.
    • deae296 Merge pull request #651 from magnetikonline/fix-golang-windows-example
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump actions/cache from 2 to 3

    Bump actions/cache from 2 to 3

    Bumps actions/cache from 2 to 3.

    Release notes

    Sourced from actions/cache's releases.

    v3.0.0

    • This change adds a minimum runner version(node12 -> node16), which can break users using an out-of-date/fork of the runner. This would be most commonly affecting users on GHES 3.3 or before, as those runners do not support node16 actions and they can use actions from github.com via github connect or manually copying the repo to their GHES instance.

    • Few dependencies and cache action usage examples have also been updated.

    v2.1.7

    Support 10GB cache upload using the latest version 1.0.8 of @actions/cache

    v2.1.6

    • Catch unhandled "bad file descriptor" errors that sometimes occurs when the cache server returns non-successful response (actions/cache#596)

    v2.1.5

    • Fix permissions error seen when extracting caches with GNU tar that were previously created using BSD tar (actions/cache#527)

    v2.1.4

    • Make caching more verbose #650
    • Use GNU tar on macOS if available #701

    v2.1.3

    • Upgrades @actions/core to v1.2.6 for CVE-2020-15228. This action was not using the affected methods.
    • Fix error handling in uploadChunk where 400-level errors were not being detected and handled correctly

    v2.1.2

    • Adds input to limit the chunk upload size, useful for self-hosted runners with slower upload speeds
    • No-op when executing on GHES

    v2.1.1

    • Update @actions/cache package to v1.0.2 which allows cache action to use posix format when taring files.

    v2.1.0

    • Replaces the http-client with the Azure Storage SDK for NodeJS when downloading cache content from Azure. This should help improve download performance and reliability as the SDK downloads files in 4 MB chunks, which can be parallelized and retried independently
    • Display download progress and speed
    Commits
    • 4b0cf6c Merge pull request #769 from actions/users/ashwinsangem/bump_major_version
    • 60c606a Update licensed files
    • b6e9a91 Revert "Updated to the latest version."
    • c842503 Updated to the latest version.
    • 2b7da2a Bumped up to a major version.
    • deae296 Merge pull request #651 from magnetikonline/fix-golang-windows-example
    • c7c46bc Merge pull request #707 from duxtland/main
    • 6535c5f Regenerated examples.md TOC
    • 3fdafa4 Update GitHub Actions status badge markdown in README.md
    • 341e6d7 Merge branch 'actions:main' into fix-golang-windows-example
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Recommend a better golang package for datetime

    Recommend a better golang package for datetime

    Carbon is a simple, semantic and developer-friendly golang package for datetime, it has been included by awesome-go

    https://github.com/golang-module/carbon

  • Bump actions/cache from 2 to 3.0.11

    Bump actions/cache from 2 to 3.0.11

    Bumps actions/cache from 2 to 3.0.11.

    Release notes

    Sourced from actions/cache's releases.

    v3.0.11

    What's Changed

    New Contributors

    Full Changelog: https://github.com/actions/cache/compare/v3...v3.0.11

    v3.0.10

    • Fix a bug with sorting inputs.
    • Update definition for restore-keys in README.md

    v3.0.9

    • Enhanced the warning message for cache unavailability in case of GHES.

    v3.0.8

    What's Changed

    • Fix zstd not working for windows on gnu tar in issues.
    • Allow users to provide a custom timeout as input for aborting cache segment download using the environment variable SEGMENT_DOWNLOAD_TIMEOUT_MIN. Default is 60 minutes.

    v3.0.7

    What's Changed

    • Fix for the download stuck problem has been added in actions/cache for users who were intermittently facing the issue. As part of this fix, new timeout has been introduced in the download step to stop the download if it doesn't complete within an hour and run the rest of the workflow without erroring out.

    v3.0.6

    What's Changed

    • Add example for clojure lein project dependencies by @​shivamarora1 in PR actions/cache#835
    • Update toolkit's cache npm module to latest. Bump cache version to v3.0.6 by @​pdotl in PR actions/cache#887
    • Fix issue #809 where cache save/restore was failing for Amazon Linux 2 runners due to older tar version
    • Fix issue #833 where cache save was not working for caching github workspace directory

    New Contributors

    Full Changelog: https://github.com/actions/cache/compare/v3...v3.0.6

    v3.0.5

    Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit.

    v3.0.4

    In this release, we have fixed the tar creation error while trying to create it with path as ~/ home folder on ubuntu-latest.

    v3.0.3

    Fixed avoiding empty cache save when no files are available for caching. (actions/cache#624)

    v3.0.2

    ... (truncated)

    Changelog

    Sourced from actions/cache's changelog.

    3.0.11

    • Update toolkit version to 3.0.5 to include @actions/core@^1.10.0
    • Update @actions/cache to use updated saveState and setOutput functions from @actions/core@^1.10.0
    Commits
    • 9b0c1fc Merge pull request #956 from actions/pdotl-version-bump
    • 18103f6 Fix licensed status error
    • 3e383cd Update RELEASES
    • 43428ea toolkit versioon update and version bump for cache
    • 1c73980 3.0.11
    • a3f5edc Merge pull request #950 from rentziass/rentziass/update-actions-core
    • 831ee69 Update licenses
    • b9c8bfe Update @​actions/core to 1.10.0
    • 0f20846 Merge pull request #946 from actions/Phantsure-patch-2
    • 862fc14 Update README.md
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • Bump actions/setup-go from 2 to 3.2.1

    Bump actions/setup-go from 2 to 3.2.1

    Bumps actions/setup-go from 2 to 3.2.1.

    Release notes

    Sourced from actions/setup-go's releases.

    Update actions/cache version to 3.0.0

    In scope of this release we updated actions/cache package as the new version contains fixes for caching error handling

    Support for caching dependency files and compiler's build outputs

    This release introduces support for caching dependency files and compiler's build outputs #228. For that action uses @​toolkit/cache library under the hood that in turn allows getting rid of configuring @​actions/cache action separately and simplifies the whole workflow.

    Such input parameters as cache and cache-dependency-path were added. The cache input is optional, and caching is turned off by default, cache-dependency-path is used to specify the path to a dependency file - go.sum.

    Examples of use-cases:

    • cache input only:
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-go@v3
      with:
        go-version: '18'
        cache: true
    
    • cache along with cache-dependency-path:
    steps:
    - uses: actions/checkout@v3
    - uses: actions/setup-go@v3
      with:
        go-version: '18'
        cache: true
        cache-dependency-path: subdir/go.sum
    

    Add go-version-file input

    Adding Go version file support

    In scope of this release we add the go-version-file input. The new input (go-version-file) provides functionality to specify the path to the file containing Go version with such behaviour:

    • If the file does not exist the action will throw an error.
    • If you specify both go-version and go-version-file inputs, the action will use value from the go-version input and throw the following warning: Both go-version and go-version-file inputs are specified, only go-version will be used.
    • For now the action supports .go-version and go.mod files.
    steps:
     - uses: actions/checkout@v3
     - uses: actions/setup-go@v3
       with:
         go-version-file: 'path/to/go.mod'
     - run: go version
    

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • How about add a maxTime and a minTime const

    How about add a maxTime and a minTime const

    Describe the feature

    Provide min and max timestamp (just like math.MaxInt, math.MinInt)

    Motivation

    Sometimes I have to decide whether a timestamp in a valid range (after the begin time stamp and before the end time stamp).

    It's convenient if I have a MaxTime so that any certainTime.Before(maxTime) is true

    Related Issues

Carbon for Golang, an extension for Time

Carbon A simple extension for Time based on PHP's Carbon library. Features: Time is embedded into Carbon (provides access to all of Time's functionali

Dec 20, 2022
:clock1: Date and Time - Golang Formatting Library
:clock1: Date and Time - Golang Formatting Library

Kair Date and Time - Golang Formatting Library Setup To get Kair > Go CLI go get github.com/GuilhermeCaruso/kair > Go DEP dep ensure -add github.com/G

Sep 26, 2022
Golang package to manipulate time intervals.

timespan timespan is a Go library for interacting with intervals of time, defined as a start time and a duration. Documentation API Installation Insta

Sep 26, 2022
timeutil - useful extensions (Timedelta, Strftime, ...) to the golang's time package

timeutil - useful extensions to the golang's time package timeutil provides useful extensions (Timedelta, Strftime, ...) to the golang's time package.

Dec 22, 2022
time format golang

a simple plugin to change date and time format

Sep 29, 2021
Go-timeparser - Flexible Time Parser for Golang

go-timeparser Flexible Time Parser for Golang Installation Download timeparser w

Dec 29, 2022
:clock8: Better time duration formatting in Go!

durafmt durafmt is a tiny Go library that formats time.Duration strings (and types) into a human readable format. go get github.com/hako/durafmt Why

Dec 16, 2022
Go time library inspired by Moment.js

Goment Current Version: 1.4.0 Changelog Goment is a port of the popular Javascript datetime library Moment.js. It follows the Moment.js API closely, w

Dec 24, 2022
fasttime - fast time formatting for go

fasttime - fast time formatting for go

Dec 13, 2022
🌐 A time zone helper
🌐 A time zone helper

?? A time zone helper tz helps you schedule things across time zones. It is an interactive TUI program that displays time across a few time zones of y

Dec 29, 2022
Clock is a small library for mocking time in Go.

clock Clock is a small library for mocking time in Go. It provides an interface around the standard library's time package so that the application can

Dec 30, 2022
A natural language date/time parser with pluggable rules

when when is a natural language date/time parser with pluggable rules and merge strategies Examples tonight at 11:10 pm at Friday afternoon the deadli

Dec 26, 2022
Copy of stdlib's time.Duration, but ParseDuration accepts other bigger units such as days, weeks, months and years

duration Copy of stdlib's time.Duration, but ParseDuration accepts other units as well: d: days (7 * 24 * time.Hour) w: weeks (7 * Day) mo: months (30

Jun 21, 2022
Structural time package for jalali calendar

Jalali Structural time package for jalali calendar. This package support parse from string, json and time. Structures There are three data structures

Mar 21, 2022
Timediff is a Go package for printing human readable, relative time differences 🕰️

timediff is a Go package for printing human readable, relative time differences. Output is based on ranges defined in the Day.js JavaScript library, and can be customized if needed.

Dec 25, 2022
Show time by timezone

Show time by timezone

Jan 22, 2022
GoLang Parse many date strings without knowing format in advance.

Go Date Parser Parse many date strings without knowing format in advance. Uses a scanner to read bytes and use a state machine to find format. Much fa

Dec 31, 2022
Convert string to duration in golang

Go String To Duration (go-str2duration) This package allows to get a time.Duration from a string. The string can be a string retorned for time.Duratio

Dec 7, 2022
A simple, semantic and developer-friendly golang package for datetime

Carbon 中文 | English carbon 是一个轻量级、语义化、对开发者友好的 Golang 时间处理库,支持链式调用和 gorm、xorm、zorm 等主流 orm。 如果您觉得不错,请给个 star 吧 github:github.com/golang-module/carbon g

Jan 9, 2023