{"id":13412500,"url":"https://github.com/leekchan/timeutil","last_synced_at":"2026-02-07T03:32:36.492Z","repository":{"id":35784725,"uuid":"40065229","full_name":"leekchan/timeutil","owner":"leekchan","description":"timeutil - useful extensions (Timedelta, Strftime, ...) to the golang's time package","archived":false,"fork":false,"pushed_at":"2019-02-03T13:14:43.000Z","size":119,"stargazers_count":192,"open_issues_count":2,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-25T10:19:31.302Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leekchan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-02T01:32:06.000Z","updated_at":"2024-06-13T21:20:47.000Z","dependencies_parsed_at":"2022-09-04T02:02:21.860Z","dependency_job_id":null,"html_url":"https://github.com/leekchan/timeutil","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leekchan/timeutil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leekchan%2Ftimeutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leekchan%2Ftimeutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leekchan%2Ftimeutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leekchan%2Ftimeutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leekchan","download_url":"https://codeload.github.com/leekchan/timeutil/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leekchan%2Ftimeutil/sbom","scorecard":{"id":582709,"data":{"date":"2025-08-11","repo":{"name":"github.com/leekchan/timeutil","commit":"28917288c48df3d2c1cfe468c273e0b2adda0aa5"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/15 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-20T19:36:23.484Z","repository_id":35784725,"created_at":"2025-08-20T19:36:23.484Z","updated_at":"2025-08-20T19:36:23.484Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29185344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T00:44:15.062Z","status":"online","status_checked_at":"2026-02-07T02:00:07.217Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:25.426Z","updated_at":"2026-02-07T03:32:36.470Z","avatar_url":"https://github.com/leekchan.png","language":"Go","funding_links":[],"categories":["Date and Time","Date \u0026 Time","日期和时间","Relational Databases","日期和时间`用于处理日期和时间的库`","\u003cspan id=\"日期和时间-date-and-time\"\u003e日期和时间 Date and Time\u003c/span\u003e","日期和時間"],"sub_categories":["Search and Analytic Databases","Advanced Console UIs","检索及分析资料库","高级控制台界面","SQL 查询语句构建库","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","高級控制台界面"],"readme":"# timeutil - useful extensions to the golang's time package\n[![Build Status](https://travis-ci.org/leekchan/timeutil.svg?branch=master)](https://travis-ci.org/leekchan/timeutil)\n[![Coverage Status](https://coveralls.io/repos/leekchan/timeutil/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/leekchan/timeutil?branch=master)\n[![GoDoc](https://godoc.org/github.com/leekchan/timeutil?status.svg)](https://godoc.org/github.com/leekchan/timeutil)\n\ntimeutil provides useful extensions (Timedelta, Strftime, ...) to the golang's time package.\n\n\n## Quick Start\n\n```\ngo get github.com/leekchan/timeutil\n```\n\nexample.go\n\n```Go\npackage main\n\nimport (\n    \"fmt\"\n    \"time\"\n\n    \"github.com/leekchan/timeutil\"\n)\n\nfunc main() {\n    // Timedelta\n    // A basic usage.\n    base := time.Date(2015, 2, 3, 0, 0, 0, 0, time.UTC)\n    td := timeutil.Timedelta{Days: 10, Minutes: 17, Seconds: 56}\n\n    result := base.Add(td.Duration())\n    fmt.Println(result) // \"2015-02-13 00:17:56 +0000 UTC\"\n\n    // Operation : Add\n    base = time.Date(2015, 2, 3, 0, 0, 0, 0, time.UTC)\n\n    td = timeutil.Timedelta{Days: 1, Minutes: 1, Seconds: 1}\n    td2 := timeutil.Timedelta{Days: 2, Minutes: 2, Seconds: 2}\n    td = td.Add(\u0026td2) // td = td + td2\n\n    result = base.Add(td.Duration())\n    fmt.Println(result) // \"2015-02-06 00:03:03 +0000 UTC\"\n\n    // Operation : Subtract\n    base = time.Date(2015, 2, 3, 0, 0, 0, 0, time.UTC)\n\n    td = timeutil.Timedelta{Days: 2, Minutes: 2, Seconds: 2}\n    td2 = timeutil.Timedelta{Days: 1, Minutes: 1, Seconds: 1}\n    td = td.Subtract(\u0026td2) // td = td - td2\n\n    result = base.Add(td.Duration())\n    fmt.Println(result) // \"2015-02-04 00:01:01 +0000 UTC\"\n\n    // Operation : Abs\n    base = time.Date(2015, 2, 3, 0, 0, 0, 0, time.UTC)\n\n    td = timeutil.Timedelta{Days: 1, Minutes: 1, Seconds: 1}\n    td2 = timeutil.Timedelta{Days: 2, Minutes: 2, Seconds: 2}\n    td = td.Subtract(\u0026td2) // td = td - td2\n    td = td.Abs()          // td = |td|\n\n    result = base.Add(td.Duration())\n    fmt.Println(result) // \"2015-02-04 00:01:01 +0000 UTC\"\n    \n    \n    // Strftime\n    date := time.Date(2015, 7, 2, 15, 24, 30, 35, time.UTC)\n    str := timeutil.Strftime(\u0026date, \"%a %b %d %I:%M:%S %p %Y\")\n    fmt.Println(str) // \"Thu Jul 02 03:24:30 PM 2015\"\n    \n    // Unicode support\n    str = timeutil.Strftime(\u0026date, \"작성일 : %a %b %d %I:%M:%S %p %Y\")\n    fmt.Println(str) // \"작성일 : Thu Jul 02 03:24:30 PM 2015\"\n}\n```\n\n\n## Timedelta\n\nTimedelta represents a duration between two dates. (inspired by python's timedelta)\n\n### Timedelta struct\n\n```Go\ntype Timedelta struct {\n    Days, Seconds, Microseconds, Milliseconds, Minutes, Hours, Weeks time.Duration\n}\n```\n\n### Initialization\n\nAll fields are optional and default to 0. You can initialize any type of timedelta by specifying field values which you want to use.\n\n**Examples:**\n\n```Go\ntd := timeutil.Timedelta{Days: 10}\ntd = timeutil.Timedelta{Minutes: 17}\ntd = timeutil.Timedelta{Seconds: 56}\ntd = timeutil.Timedelta{Days: 10, Minutes: 17, Seconds: 56}\ntd = timeutil.Timedelta{Days: 1, Seconds: 1, Microseconds: 1, Milliseconds: 1, Minutes: 1, Hours: 1, Weeks: 1}\n```\n\n### func (t *Timedelta) Duration() time.Duration\n\nDuration() returns time.Duration. time.Duration can be added to time.Date.\n\n**Examples:**\n\n```Go\nbase := time.Date(2015, 2, 3, 0, 0, 0, 0, time.UTC)\ntd := timeutil.Timedelta{Days: 10, Minutes: 17, Seconds: 56}\n\nresult := base.Add(td.Duration())\nfmt.Println(result) // \"2015-02-13 00:17:56 +0000 UTC\"\n```\n\n### Operations\n\n#### func (t *Timedelta) Add(t2 *Timedelta)\n\nAdd returns the Timedelta t+t2.\n\n**Examples:**\n\n```Go\nbase := time.Date(2015, 2, 3, 0, 0, 0, 0, time.UTC)\ntd := timeutil.Timedelta{Days: 1, Minutes: 1, Seconds: 1}\ntd2 := timeutil.Timedelta{Days: 2, Minutes: 2, Seconds: 2}\ntd = td.Add(\u0026td2) // td = td + td2\n\nresult = base.Add(td.Duration())\nfmt.Println(result) // \"2015-02-06 00:03:03 +0000 UTC\"\n```\n\n#### func (t *Timedelta) Subtract(t2 *Timedelta) Timedelta\n\nSubtract returns the Timedelta t-t2.\n\n**Examples:**\n\n```Go\nbase := time.Date(2015, 2, 3, 0, 0, 0, 0, time.UTC)\n\ntd := timeutil.Timedelta{Days: 2, Minutes: 2, Seconds: 2}\ntd2 := timeutil.Timedelta{Days: 1, Minutes: 1, Seconds: 1}\ntd = td.Subtract(\u0026td2) // td = td - td2\n\nresult = base.Add(td.Duration())\nfmt.Println(result) // \"2015-02-04 00:01:01 +0000 UTC\"\n```\n\n#### func (t *Timedelta) Abs() Timedelta\n\nAbs returns the absolute value of t\n\n**Examples:**\n\n```Go\nbase := time.Date(2015, 2, 3, 0, 0, 0, 0, time.UTC)\n\ntd := timeutil.Timedelta{Days: 1, Minutes: 1, Seconds: 1}\ntd2 := timeutil.Timedelta{Days: 2, Minutes: 2, Seconds: 2}\ntd = td.Subtract(\u0026td2) // td = td - td2\ntd = td.Abs() // td = |td|\n\nresult = base.Add(td.Duration())\nfmt.Println(result) // \"2015-02-04 00:01:01 +0000 UTC\"\n```\n\n\n## Strftime\n\nStrftime formats time.Date according to the directives in the given format string. The directives begins with a percent (%) character.\n\n(Strftime supports unicode format string.)\n\n\nDirective | Meaning | Example\n-------------| ------------- | -------------\n%a | Weekday as locale’s abbreviated name. | Sun, Mon, ..., Sat\n%A | Weekday as locale’s full name.     | Sunday, Monday, ..., Saturday \n%w | Weekday as a decimal number, where 0 is Sunday and 6 is Saturday | 0, 1, ..., 6     \n%d | Day of the month as a zero-padded decimal number. | 01, 02, ..., 31 \n%b | Month as locale’s abbreviated name. | Jan, Feb, ..., Dec\n%B | Month as locale’s full name. | January, February, ..., December\n%m | Month as a zero-padded decimal number. | 01, 02, ..., 12\n%y | Year without century as a zero-padded decimal number. | 00, 01, ..., 99\n%Y | Year with century as a decimal number. |   1970, 1988, 2001, 2013\n%H | Hour (24-hour clock) as a zero-padded decimal number. | 00, 01, ..., 23\n%I | Hour (12-hour clock) as a zero-padded decimal number. | 01, 02, ..., 12 \n%p | Meridian indicator. (AM or PM.) | AM, PM\n%M | Minute as a zero-padded decimal number. | 00, 01, ..., 59\n%S | Second as a zero-padded decimal number. | 00, 01, ..., 59\n%f | Microsecond as a decimal number, zero-padded on the left. | 000000, 000001, ..., 999999\n%z | UTC offset in the form +HHMM or -HHMM | +0000\n%Z | Time zone name | UTC\n%j | Day of the year as a zero-padded decimal number | 001, 002, ..., 366\n%U | Week number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. | 00, 01, ..., 53 \n%W | Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0.   | 00, 01, ..., 53\n%c | Date and time representation. | Tue Aug 16 21:30:00 1988\n%x | Date representation. | 08/16/88\n%X | Time representation. | 21:30:00\n%% | A literal '%' character. | %\n\n**Examples:**\n\n```Go\ndate := time.Date(2015, 7, 2, 15, 24, 30, 35, time.UTC)\nstr := timeutil.Strftime(\u0026date, \"%a %b %d %I:%M:%S %p %Y\")\nfmt.Println(str) // \"Thu Jul 02 03:24:30 PM 2015\"\n\n// Unicode support\nstr = timeutil.Strftime(\u0026date, \"작성일 : %a %b %d %I:%M:%S %p %Y\")\nfmt.Println(str) // \"작성일 : Thu Jul 02 03:24:30 PM 2015\"\n```\n\n## TODO\n\n* Locale support\n* Strptime - a function which returns a time.Date parsed according to a format string\n* Auto date parser - a generic string parser which is able to parse most known formats to represent a date\n* And other useful features...","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleekchan%2Ftimeutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleekchan%2Ftimeutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleekchan%2Ftimeutil/lists"}