math

rolex.math.add_seconds(datetime_like_object, n, return_date=False)[source]

Returns a time that n seconds after a time.

Parameters:
  • datetimestr – a datetime object or a datetime str
  • n – number of seconds, value can be negative

中文文档

返回给定日期N秒之后的时间。

rolex.math.add_minutes(datetime_like_object, n, return_date=False)[source]

Returns a time that n minutes after a time.

Parameters:
  • datetimestr – a datetime object or a datetime str
  • n – number of minutes, value can be negative

中文文档

返回给定日期N分钟之后的时间。

rolex.math.add_hours(datetime_like_object, n, return_date=False)[source]

Returns a time that n hours after a time.

Parameters:
  • datetimestr – a datetime object or a datetime str
  • n – number of hours, value can be negative

中文文档

返回给定日期N小时之后的时间。

rolex.math.add_days(datetime_like_object, n, return_date=False)[source]

Returns a time that n days after a time.

Parameters:
  • datetimestr – a datetime object or a datetime str
  • n – number of days, value can be negative
  • return_date – returns a date object instead of datetime

中文文档

返回给定日期N天之后的时间。

rolex.math.add_weeks(datetime_like_object, n, return_date=False)[source]

Returns a time that n weeks after a time.

Parameters:
  • datetimestr – a datetime object or a datetime str
  • n – number of weeks, value can be negative
  • return_date – returns a date object instead of datetime

中文文档

返回给定日期N周之后的时间。

rolex.math.add_months(datetime_like_object, n, return_date=False)[source]

Returns a time that n months after a time.

Notice: for example, the date that one month after 2015-01-31 supposed to be 2015-02-31. But there’s no 31th in Feb, so we fix that value to 2015-02-28.

Parameters:
  • datetimestr – a datetime object or a datetime str
  • n – number of months, value can be negative
  • return_date – returns a date object instead of datetime

中文文档

返回给定日期N月之后的时间。

rolex.math.add_years(datetime_like_object, n, return_date=False)[source]

Returns a time that n years after a time.

Parameters:
  • datetimestr – a datetime object or a datetime str
  • n – number of years, value can be negative
  • return_date – returns a date object instead of datetime

中文文档

返回给定日期N年之后的时间。

rolex.math.round_to(dt, hour, minute, second, mode='round')[source]

Round the given datetime to specified hour, minute and second.

Parameters:mode – ‘floor’ or ‘ceiling’

New in version 0.0.5: message

中文文档

将给定时间对齐到最近的一个指定了小时, 分钟, 秒的时间上。