def time_hours(self): """ Returns a string representation of the begin and end time. Only the time is used, the date is not shown. """ return "%s - %s" % (date_f(localtime(self.begin), 'TIME_FORMAT'), date_f(localtime(self.end), 'TIME_FORMAT'))
def time(self): """ Returns a string representation of the begin and end time. The begin contains the date and time, the end only the time. """ return "%s, %s - %s" % (date_f(localtime(self.begin), 'DATE_FORMAT'), date_f(localtime(self.begin), 'TIME_FORMAT'), date_f(localtime(self.end), 'TIME_FORMAT'))
def time_with_day(self): """ Returns a string representation of the day. If the shift is on two days only the name of the first day is returned. """ day = date_f(localtime(self.begin), "l") return "{}, {}".format(day, self.time())
def _get_auto_shift_text(self, helper, primary_job, badgesettings): """ We create a string like: Shift 1, Shift 2 (Other job), Shift 3 Depending on the settings, we use the shift name (if available) or the time in a certain format. The job is added if it is not the primary job. Returns the text (not LaTeX escaped!) """ shift_texts = [] for shift in helper.shifts.all().order_by('begin'): # get shift date / name cur_text = "" if not badgesettings.shift_no_names and shift.name: # we want to use a name and have one cur_text = shift.name else: # use time. format depends on settings, but we always needs the time cur_text = shift.time_hours() # the date format depends on the settings date_format_string = None if badgesettings.shift_format == BadgeSettings.SHIFT_FORMAT_DATE: date_format_string = "d.m" elif badgesettings.shift_format == BadgeSettings.SHIFT_FORMAT_WEEKDAY: date_format_string = "D" # add the date, if we want to if date_format_string: cur_text = "{} {}".format( date_f(shift.date(), date_format_string), cur_text) # add job if it is not the primary job if shift.job != primary_job: cur_text = "{} ({})".format(cur_text, shift.job.name) shift_texts.append(cur_text) return ', '.join(shift_texts)
def __str__(self): return "{} - {} - {}".format( date_f(localtime(self.timestamp), 'DATETIME_FORMAT'), self.level, self.message, )