mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
region misc fix:
- guest postpaid expire support set expire time - list instance snapshot sub snapshot return size
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user