| | |
| | | # @return 返回值. 是否通过检查
|
| | | # @remarks 概率相关, 这个事件是否能够出现
|
| | | def CanHappen(rate, maxRate=ShareDefine.Def_MaxRateValue):
|
| | | if random.randint(0, maxRate -1) < rate:
|
| | | if rate <= 0:
|
| | | return 0
|
| | | if rate >= maxRate or random.randint(0, maxRate -1) < rate:
|
| | | return 1
|
| | |
|
| | | return 0
|
| | |
| | | dateTimeB = ChangeTimeNumToDatetime(timeB)
|
| | | dateTimeB = datetime.datetime(dateTimeB.year, dateTimeB.month, dateTimeB.day, 0, 0, 0)
|
| | | return (dateTimeA - dateTimeB).days
|
| | |
|
| | | def GetEndTimeByZeroTime(startTime, addDays):
|
| | | ## 获取结束时间,根据0点结束计算
|
| | | # @param startTime: 起始时间戳
|
| | | # @param addDays: 增加的天数,如果是1天实际为当天,即1代表当天
|
| | | startDate = ChangeTimeNumToDatetime(startTime)
|
| | | startZeroDate = datetime.datetime(startDate.year, startDate.month, startDate.day, 23, 59, 59)
|
| | | startZeroTime = int(time.mktime(startZeroDate.timetuple()))
|
| | | endTime = startTime + (startZeroTime - startTime) + max(addDays - 1, 0) * 24 * 3600
|
| | | return endTime
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | | ##获取与当前时间相差天数的datetime格式数据
|
| | |
| | | randList = []
|
| | | weight = 0
|
| | | for info in weightList:
|
| | | if not info[0]:
|
| | | continue
|
| | | weight += info[0]
|
| | | randList.append([weight, info[1] if len(info) == 2 else info[1:]])
|
| | | if not randList:
|