region misc fix:

- guest postpaid expire support set expire time
- list instance snapshot sub snapshot return size
This commit is contained in:
wanyaoqi
2020-02-21 17:17:30 +08:00
parent b621135c35
commit 981222867f
4 changed files with 40 additions and 11 deletions
+9
View File
@@ -37,6 +37,7 @@ const (
var (
ErrInvalidBillingCycle = errors.New("invalid billing cycle")
ErrInvalidDuration = errors.New("invalid duration")
)
type SBillingCycle struct {
@@ -74,6 +75,14 @@ func ParseBillingCycle(cycleStr string) (SBillingCycle, error) {
return cycle, nil
}
// parse duration to minute unit billing cycle
func DurationToBillingCycle(dur time.Duration) SBillingCycle {
return SBillingCycle{
Unit: BillingCycleMinute,
Count: int(dur.Minutes()),
}
}
func (cycle *SBillingCycle) String() string {
return fmt.Sprintf("%d%s", cycle.Count, cycle.Unit)
}