
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
github.com/siverpinevalley/parseduration
The built-in package time offer very useful functions.
However, when you use time.ParseDuration, you cannot use time unit that is bigger than hours. This package also offer day, week, month, year time units for parsing string to duration.
go get https://github.com/SiverPineValley/parseduration
The standard for parsing is same as time.ParseDuration. You can use ParseDuration
sending parameters such as 2w3d20h
.
Negative numbers are also provided, and if you enter only letters without entering a number, it will be recognized as 0. d == 0d
Time units are as provided in the table below. A time unit that is not provided or a time unit that is duplicated will cause an error.
In addition, the maximum value for each unit was not separately filtered.
Time Unit | Duration |
---|---|
ns | 1 Nano seconds |
us | 1 Micro Seconds |
ms | 1 Milli Seconds |
s | 1 Seconds |
m | 1 Minutes |
h | 1 Hours |
d | 1 Days |
w | 1 Weeks (7 Days) |
M | 1 Months (30 Days) |
y | 1 Years (365 Days) |
package main
import (
"fmt"
pd "github.com/SiverPineValley/parseduration"
)
// It returns 4 weeks + 2 days + 3 hours Duration
func main() {
fmt.Println(pd.ParseDuration("4w2d3h"))
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.