{"id":49895029,"url":"https://github.com/yylego/timezh","last_synced_at":"2026-05-15T23:05:27.216Z","repository":{"id":355664186,"uuid":"1178717520","full_name":"yylego/timezh","owner":"yylego","description":"Chinese-named time manipulation and formatting package","archived":false,"fork":false,"pushed_at":"2026-04-08T15:57:47.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-04T19:07:31.127Z","etag":null,"topics":["chinese-programming","date-conversion","time-formatting","timezone"],"latest_commit_sha":null,"homepage":null,"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/yylego.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-11T09:47:51.000Z","updated_at":"2026-04-08T15:55:00.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/yylego/timezh","commit_stats":null,"previous_names":["yylego/timezh"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/yylego/timezh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Ftimezh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Ftimezh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Ftimezh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Ftimezh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yylego","download_url":"https://codeload.github.com/yylego/timezh/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yylego%2Ftimezh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33082790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T20:25:35.270Z","status":"ssl_error","status_checked_at":"2026-05-15T20:25:34.732Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["chinese-programming","date-conversion","time-formatting","timezone"],"created_at":"2026-05-15T23:05:26.445Z","updated_at":"2026-05-15T23:05:27.207Z","avatar_url":"https://github.com/yylego.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/yylego/timezh/release.yml?branch=main\u0026label=BUILD)](https://github.com/yylego/timezh/actions/workflows/release.yml?query=branch%3Amain)\n[![GoDoc](https://pkg.go.dev/badge/github.com/yylego/timezh)](https://pkg.go.dev/github.com/yylego/timezh)\n[![Coverage Status](https://img.shields.io/coveralls/github/yylego/timezh/main.svg)](https://coveralls.io/github/yylego/timezh?branch=main)\n[![Supported Go Versions](https://img.shields.io/badge/Go-1.22--1.25-lightgrey.svg)](https://github.com/yylego/timezh)\n[![GitHub Release](https://img.shields.io/github/release/yylego/timezh.svg)](https://github.com/yylego/timezh/releases)\n[![Go Report Card](https://goreportcard.com/badge/github.com/yylego/timezh)](https://goreportcard.com/report/github.com/yylego/timezh)\n\n# timezh\n\nComprehensive Go package providing time operations with Chinese function names and intuitive APIs\n\n---\n\n\u003c!-- TEMPLATE (EN) BEGIN: LANGUAGE NAVIGATION --\u003e\n## CHINESE README\n\n[中文说明](README.zh.md)\n\u003c!-- TEMPLATE (EN) END: LANGUAGE NAVIGATION --\u003e\n\n---\n\n## DISCLAIMER\n\nWriting Go code in Chinese is a viable technique, but something to avoid in production engineering. This approach should not be used in serious and business settings. Teams and companies that embrace it could face contempt from peers and negative judgment across the profession. In business companies, this practice is even more prone to becoming a target of public criticism. This project is dedicated to research and academic studies. Do not use this approach in production.\n\n---\n\n## Main Features\n\n🎯 **Chinese Function Names**: Intuitive Chinese-named wrappers around Go's standard time package\n🔒 **Multiple Time Zones**: Built-in support on CST, UTC, GMT, and ICT time zones\n🎨 **Rich Format Options**: Various time/date format conversion methods\n📊 **Bidirectional Conversion**: Time ↔ String ↔ Numeric seamless conversion\n🌐 **Regex Matching**: Smart time string pattern recognition and extraction\n\n## Installation\n\n```bash\ngo get github.com/yylego/timezh\n```\n\n## Quick Start\n\n### Time to String Conversion\n\nConvert time objects to various string formats using `TS`.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/yylego/timezh\"\n)\n\nfunc main() {\n\t// Time to String conversion (时间转字符串)\n\t// Get current date in different formats (获取不同格式的当前日期)\n\tdate := timezh.TS.D日期.Get现在日期(timezh.TZ.CST)\n\tfmt.Printf(\"Current Date: %s\\n\", date) // Output: 2025-05-16\n\n\t// Get current time (获取当前时间)\n\ts时间字符串 := timezh.TS.T时间.Get现在时间(timezh.TZ.CST)\n\tfmt.Printf(\"Current Time: %s\\n\", s时间字符串) // Output: 2025-05-16 19:11:45\n\n\t// Get yesterday's date (获取昨天的日期)\n\tyesterday := timezh.TS.D日期.Get昨日日期(timezh.TZ.CST)\n\tfmt.Printf(\"Yesterday: %s\\n\", yesterday) // Output: 2025-05-15\n\n\t// Get 8-digit date format (获取8位数字格式的日期)\n\tdate8 := timezh.TS.D日期8位数.Get现在日期(timezh.TZ.CST)\n\tfmt.Printf(\"8-digit Date: %s\\n\", date8) // Output: 20250516\n\n\t// Get 14-digit time format (获取14位数字格式的时间)\n\ttime14 := timezh.TS.T时间14位数.Get现在时间(timezh.TZ.CST)\n\tfmt.Printf(\"14-digit Time: %s\\n\", time14) // Output: 20250516191145\n}\n```\n\n⬆️ **Source:** [Source](internal/demos/demo1x/main.go)\n\n### String to Time Conversion\n\nParse time strings into time objects using `ST`.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/yylego/timezh\"\n)\n\nfunc main() {\n\t// String to Time conversion (字符串转时间)\n\t// Parse standard time string (解析标准时间字符串)\n\tt1, err := timezh.ST.Get时间(\"2025-05-16 19:11:45\", timezh.TZ.CST)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"Parsed Time: %v\\n\", t1)\n\n\t// Parse just date (仅解析日期)\n\tt2, err := timezh.ST.Get通过日期得到时间(\"2025-05-16\", timezh.TZ.CST)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"Date Time: %v\\n\", t2)\n\n\t// Numeric to Time conversion (数字转时间)\n\t// Create time from date components (从日期组件创建时间)\n\tt3 := timezh.NT.New由年月日得到零时时间(2025, 5, 16, timezh.TZ.CST)\n\tfmt.Printf(\"From Components: %v\\n\", t3)\n\n\t// Timestamp to Time conversion (时间戳转时间)\n\t// Convert Unix timestamp to time (转换 Unix 时间戳为时间)\n\ttimestamp := time.Now().Unix()\n\tt4 := timezh.NS.Get秒数时间(timestamp)\n\tfmt.Printf(\"From Timestamp: %v\\n\", t4)\n\n\t// Time comparison (时间比较)\n\t// Compare time and time string (比较时间与时间字符串)\n\tnow := time.Now()\n\tisBefore := timezh.CS.B时间在时分秒后面(now, \"23:59:59\")\n\tfmt.Printf(\"Before 23:59:59: %v\\n\", isBefore)\n}\n```\n\n⬆️ **Source:** [Source](internal/demos/demo2x/main.go)\n\n### Time Zone Operations\n\nWork with different time zones and calculate time differences.\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/yylego/timezh\"\n)\n\nfunc main() {\n\t// Working with Time Zones (时区操作)\n\t// Get current date in CST (获取 CST 时区的当前日期)\n\tdateCST := timezh.TS.D日期.Get现在日期(timezh.TZ.CST)\n\tfmt.Printf(\"CST Date: %s\\n\", dateCST) // Output: 2025-05-16\n\n\t// Get current date in UTC (获取 UTC 时区的当前日期)\n\tdateUTC := timezh.TS.D日期.Get现在日期(timezh.TZ.UTC)\n\tfmt.Printf(\"UTC Date: %s\\n\", dateUTC) // Output: 2025-05-16\n\n\t// Get current date in ICT (获取 ICT 时区的当前日期)\n\tdateICT := timezh.TS.D日期.Get现在日期(timezh.TZ.ICT)\n\tfmt.Printf(\"ICT Date: %s\\n\", dateICT) // Output: 2025-05-16\n\n\t// Get recent business days (获取最近的工作日)\n\t// Get the most recent 5 business days including today (获取包括今天在内的最近5个工作日)\n\tworkdays := timezh.TS.D日期.Get最近含当日的前N个工作日(5, timezh.TZ.CST)\n\tfmt.Printf(\"Recent Workdays: %v\\n\", workdays) // Output: [\"2025-05-16\", \"2025-05-15\", \"2025-05-14\", \"2025-05-13\", \"2025-05-12\"]\n\n\t// Calculate time difference (计算时间差)\n\tduration, err := timezh.SD.Get两字符串时间间隔(\"2025-05-16 20:00:00\", \"2025-05-16 19:00:00\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\thours := duration.Hours()\n\tfmt.Printf(\"Time Difference: %.0f hours\\n\", hours) // Output: 1 hours\n}\n```\n\n⬆️ **Source:** [Source](internal/demos/demo3x/main.go)\n\n## API Reference\n\n### Core Modules\n\n#### TS - Time to String (时间转字符串)\n\nTime formatting module with predefined format templates:\n\n- `TS.D日期` - Date format \"2006-01-02\"\n- `TS.Y年份` - Just the \"2006\" component\n- `TS.D月日` - Month-Day \"01-02\"\n- `TS.T时刻` - Just time \"15:04:05\"\n- `TS.T时间` - Complete datetime \"2006-01-02 15:04:05\"\n- `TS.T日期和T和时刻` - ISO 8601 format \"2006-01-02T15:04:05\"\n- `TS.T时间14位数` - 14-digit format \"20060102150405\"\n- `TS.D日期8位数` - 8-digit date \"20060102\"\n- `TS.T时刻6位数` - 6-digit time \"150405\"\n\n**Main Methods:**\n- `Get转字符串(t time.Time) string` - Convert time to string\n- `Get现在日期(z时区位置 *time.Location) string` - Get current date\n- `Get昨日日期(z时区位置 *time.Location) string` - Get yesterday's date\n- `Get最近含当日的前N个工作日(n int, z时区位置 *time.Location) []string` - Get recent N business days\n\n#### ST - String to Time (字符串转时间)\n\nString parsing module:\n\n- `Get时间(s标准时间 string, z时区位置 *time.Location) (time.Time, error)` - Parse \"2006-01-02 15:04:05\"\n- `Get日期和分时(s标准时间没有秒数 string, z时区位置 *time.Location) (time.Time, error)` - Parse \"2006-01-02 15:04\"\n- `Get通过日期得到时间(s标准日期 string, z时区位置 *time.Location) (time.Time, error)` - Parse \"2006-01-02\"\n- `Get通过时刻得到当日时间(s标准时刻 string, z时区位置 *time.Location) (time.Time, error)` - Parse \"15:04:05\"\n\n#### NT - Numeric to Time (数字转时间)\n\nConstruct time from numeric components:\n\n- `New由年月日得到零时时间(year, month, day int, z时区位置 *time.Location) time.Time`\n- `New由当日时分秒得到时间(hour, minute, second int, z时区位置 *time.Location) time.Time`\n\n#### NS - Timestamp to Time (时间戳转时间)\n\nConvert Unix timestamps to time objects:\n\n- `Get秒数时间(sn总秒数 int64) time.Time`\n- `Get毫秒时间(ms微秒数 int64) time.Time`\n- `Get微秒时间(ms微秒数 int64) time.Time`\n- `Get纳秒时间(ns纳秒数 int64) time.Time`\n\n#### TI - Time to Numeric (时间转数量)\n\nExtract numeric components from time:\n\n- `Get年份(t time.Time) int`\n- `Get年份和月份(t time.Time) (int, int)`\n- `Get年份月份几号(t time.Time) (int, int, int)`\n- `Get几时几分秒数(t time.Time) (int, int, int)`\n- `Get数量(t time.Time) (int, int, int, int, int, int)` - Extract components\n\n#### CS - Compare Strings (比较字符串)\n\nCompare time strings:\n\n- `I在时分秒内含边界(t time.Time, s起始时刻, e结束时刻 string) bool`\n- `A时间在时分秒前面(t time.Time, s时刻 string) bool`\n- `B时间在时分秒后面(t time.Time, s时刻 string) bool`\n\n#### SD - String Duration (字符串间隔)\n\nCalculate time differences between strings:\n\n- `Get两字符串时间间隔(s开始时间, e结束时间 string) (time.Duration, error)`\n\n#### RS - Regex String (正则匹配)\n\nExtract time patterns from strings:\n\n- `Get匹配时间(s string) string` - Match \"2006-01-02 15:04:05\"\n- `Get匹配日期(s string) string` - Match \"2006-01-02\"\n- `Get匹配时刻(s string) string` - Match \"15:04:05\"\n\n#### TZ - Time Zones (时区位置)\n\nBuilt-in time zone locations:\n\n- `TZ.CST` - China Standard Time (北京时间) UTC+8\n- `TZ.UTC` - Coordinated Universal Time (世界标准时间) UTC+0\n- `TZ.GMT` - Greenwich Mean Time (格林尼治标准时间) UTC+0\n- `TZ.ICT` - Indochina Time (东南亚时间) UTC+7\n\n#### WK - Week-date (星期)\n\nWeek-date operations:\n\n- `Is工作日(t time.Time) bool` - Check if business day (Mon-Fri)\n- `Is周六日(t time.Time) bool` - Check if weekend (Sat-Sun)\n\n## Examples\n\n### Working with Time Zones\n\n```go\n// CST - China Standard Time\ndateCST := timezh.TS.D日期.Get现在日期(timezh.TZ.CST)\n\n// UTC - Universal Coordinated Time\ndateUTC := timezh.TS.D日期.Get现在日期(timezh.TZ.UTC)\n\n// ICT - Indochina Time\ndateICT := timezh.TS.D日期.Get现在日期(timezh.TZ.ICT)\n```\n\n### Get Recent Business Days\n\n```go\n// Get the most recent 5 business days including today\nworkdays := timezh.TS.D日期.Get最近含当日的前N个工作日(5, timezh.TZ.CST)\n// Output: [\"2025-05-16\", \"2025-05-15\", \"2025-05-14\", \"2025-05-13\", \"2025-05-12\"]\n```\n\n### Extract Time from String\n\n```go\ntext := \"Meeting scheduled on 2025-05-16 at 14:30:00\"\ns时间字符串 := timezh.RS.Get匹配时间(text)\n// Output: \"2025-05-16 14:30:00\"\n```\n\n### Calculate Time Difference\n\n```go\nduration, err := timezh.SD.Get两字符串时间间隔(\"2025-05-16 20:00:00\", \"2025-05-16 19:00:00\")\nif err != nil {\n\tpanic(err)\n}\nhours := duration.Hours()\n// Output: 1 h\n```\n\n## Design Concept\n\nThis package follows these principles:\n\n1. **Chinese Naming**: Functions use intuitive Chinese names matching usage scenarios\n2. **Type-Safe Operations**: Leverages Go's type system to achieve safe time operations\n3. **Time Zone Awareness**: Explicit time zone handling across operations\n4. **Flexible Formats**: Multiple pre-defined and custom format support\n5. **Bidirectional Conversion**: Seamless conversion between time, string, and numeric formats\n\n---\n\n\u003c!-- TEMPLATE (EN) BEGIN: STANDARD PROJECT FOOTER --\u003e\n\u003c!-- VERSION 2025-09-26 07:39:27.188023 +0000 UTC --\u003e\n\n## 📄 License\n\nMIT License. See [LICENSE](LICENSE).\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! Report bugs, suggest features, and contribute code:\n\n- 🐛 **Found a mistake?** Open an issue on GitHub with reproduction steps\n- 💡 **Have a feature idea?** Create an issue to discuss the suggestion\n- 📖 **Documentation confusing?** Report it so we can improve\n- 🚀 **Need new features?** Share the use cases to help us understand requirements\n- ⚡ **Performance issue?** Help us optimize through reporting slow operations\n- 🔧 **Configuration problem?** Ask questions about complex setups\n- 📢 **Follow project progress?** Watch the repo to get new releases and features\n- 🌟 **Success stories?** Share how this package improved the workflow\n- 💬 **Feedback?** We welcome suggestions and comments\n\n---\n\n## 🔧 Development\n\nNew code contributions, follow this process:\n\n1. **Fork**: Fork the repo on GitHub (using the webpage UI).\n2. **Clone**: Clone the forked project (`git clone https://github.com/yourname/repo-name.git`).\n3. **Navigate**: Navigate to the cloned project (`cd repo-name`)\n4. **Branch**: Create a feature branch (`git checkout -b feature/xxx`).\n5. **Code**: Implement the changes with comprehensive tests\n6. **Testing**: (Golang project) Ensure tests pass (`go test ./...`) and follow Go code style conventions\n7. **Documentation**: Update documentation to support client-facing changes and use significant commit messages\n8. **Stage**: Stage changes (`git add .`)\n9. **Commit**: Commit changes (`git commit -m \"Add feature xxx\"`) ensuring backward compatible code\n10. **Push**: Push to the branch (`git push origin feature/xxx`).\n11. **PR**: Open a merge request on GitHub (on the GitHub webpage) with detailed description.\n\nPlease ensure tests pass and include relevant documentation updates.\n\n---\n\n## 🌟 Support\n\nWelcome to contribute to this project via submitting merge requests and reporting issues.\n\n**Project Support:**\n\n- ⭐ **Give GitHub stars** if this project helps you\n- 🤝 **Share with teammates** and (golang) programming friends\n- 📝 **Write tech blogs** about development tools and workflows - we provide content writing support\n- 🌟 **Join the ecosystem** - committed to supporting open source and the (golang) development scene\n\n**Have Fun Coding with this package!** 🎉🎉🎉\n\n\u003c!-- TEMPLATE (EN) END: STANDARD PROJECT FOOTER --\u003e\n\n---\n\n## GitHub Stars\n\n[![Stargazers](https://starchart.cc/yylego/timezh.svg?variant=adaptive)](https://starchart.cc/yylego/timezh)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyylego%2Ftimezh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyylego%2Ftimezh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyylego%2Ftimezh/lists"}