Module pywander.datetime

some datetime utils

Global variables

var one_day_ago

one day ago datetime object

var one_hour_ago

one hour ago datetime object

var one_month_ago

one month ago datetime object

var one_week_ago

one_week_ago datetime object

var two_day_ago

two day ago datetime object

var utcnow

current utcnow datetime object

Functions

def dt_to_timestamp(dt, multiplier=1)

change datetime object to timestamp

def get_datetime_range(months)

return a list of datetime range, start from current time, and counted upon previous some months.

def get_dt_fromtimestamp(timestamp, utc=False, multiplier=1)

get datetime object from timestamp

def get_timestamp(multiplier=1)

get current timestamp :return:

def is_same_day(dt1, dt2)

is the two datetime objects are in the same day

def is_same_hour(dt1, dt2)

is the two datetime objects are in the same hour

def is_same_month(dt1, dt2)

is the two datetime objects are in the same month

def is_same_year(dt1: datetime.datetime, dt2: datetime.datetime)

is the two datetime objects are in the same year

def normal_format_now()

get current normal format for now: '2018-12-21 15:39:20' :return:

def normal_format_utcnow()

get current normal format for utcnow: '2018-12-21 15:39:20' :return:

def round_to_day(dt)

round a datetime object to day

def round_to_hour(dt)

round a datetime object to hour :param dt: :return:

def round_to_minute(dt)

round a datetime object to minute

def round_to_second(dt)

round a datetime object to second