Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.