parent
35fe97d37b
commit
c21b6948cc
@ -0,0 +1,41 @@
|
|||||||
|
package rocron
|
||||||
|
|
||||||
|
func filterSeconds(seconds int) int {
|
||||||
|
if seconds <= 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if seconds > 60 {
|
||||||
|
return 60
|
||||||
|
}
|
||||||
|
return seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
func filterMinutes(minutes int) int {
|
||||||
|
if minutes <= 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if minutes > 59 {
|
||||||
|
return 59
|
||||||
|
}
|
||||||
|
return minutes
|
||||||
|
}
|
||||||
|
|
||||||
|
func filterHours(hours int) int {
|
||||||
|
if hours <= 0 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if hours > 23 {
|
||||||
|
return 23
|
||||||
|
}
|
||||||
|
return hours
|
||||||
|
}
|
||||||
|
|
||||||
|
func filterDays(days int) int {
|
||||||
|
if days <= 0 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if days > 31 {
|
||||||
|
return 31
|
||||||
|
}
|
||||||
|
return days
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package rocron
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func concatenateStrings(day int) string {
|
||||||
|
var result string
|
||||||
|
if day > 1 {
|
||||||
|
result += "1"
|
||||||
|
}
|
||||||
|
for i := 1; i <= 31; i++ {
|
||||||
|
if isDivisibleBy(i, day) {
|
||||||
|
if len(result) > 0 {
|
||||||
|
result += ","
|
||||||
|
}
|
||||||
|
result += fmt.Sprintf("%d", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func isDivisibleBy(num, divisor int) bool {
|
||||||
|
return num%divisor == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func removeFirstTwoChars(str string) string {
|
||||||
|
if len(str) > 2 {
|
||||||
|
return str[2:]
|
||||||
|
}
|
||||||
|
|
||||||
|
return ""
|
||||||
|
}
|
Loading…
Reference in new issue