Пример #1
0
    def add_call(self,
                 date: datetime.date,
                 time_begin: datetime.time,
                 time_end: datetime.time,
                 dispatch_number: Optional[int] = None,
                 sender_city_id: Optional[int] = None,
                 sender_phone: Optional[str] = None,
                 sender_name: Optional[str] = None,
                 weight: Optional[int] = None,
                 comment: Optional[str] = None,
                 lunch_begin: Optional[datetime.time] = None,
                 lunch_end: Optional[datetime.time] = None,
                 ignore_time: bool = False) -> SubElement:
        """
        Добавление вызова курьера
        :param date: дата ожидания курьера
        :param time_begin: время начала ожидания
        :param time_end: время окончания ожидания
        :param int dispatch_number: Номер привязанного заказа
        :param int sender_city_id: ID города отправителя по базе СДЭК
        :param str sender_phone: телефон оправителя
        :param str sender_name: ФИО оправителя
        :param int weight: общий вес в граммах
        :param str comment: комментарий
        :param lunch_begin: время начала обеда
        :param lunch_end: время окончания обеда
        :param bool ignore_time: Не выполнять проверки времени приезда курьера
        :return: Объект вызова
        """

        call_element = ElementTree.SubElement(
            self.call_courier_element,
            'Call',
            Date=date.isoformat(),
            TimeBeg=time_begin.isoformat(),
            TimeEnd=time_end.isoformat(),
        )

        call_element.attrib['DispatchNumber'] = dispatch_number
        call_element.attrib['SendCityCode'] = sender_city_id
        call_element.attrib['SendPhone'] = sender_phone
        call_element.attrib['SenderName'] = sender_name
        call_element.attrib['Weight'] = weight
        call_element.attrib['Comment'] = comment
        call_element.attrib['IgnoreTime'] = ignore_time

        if lunch_begin:
            call_element.attrib['LunchBeg'] = lunch_begin.isoformat()
        if lunch_end:
            call_element.attrib['LunchEnd'] = lunch_end.isoformat()

        self.calls.append(call_element)

        return call_element
Пример #2
0
    def create_time_entry(self, date: datetime.date, start_time: datetime.time,
                          end_time: datetime.time, task_id: int):
        response = requests.post(
            urllib.parse.urljoin(self.site_url, 'api/v1/time_entries'),
            params=dict(date=date.isoformat(),
                        start_time=start_time.isoformat('minutes'),
                        end_time=end_time.isoformat('minutes'),
                        task_id=task_id),
            headers={'X-Auth-Token': self.api_token})

        response.raise_for_status()

        return response.json()
Пример #3
0
 def put_reminder(self,
                  guild: int,
                  member: int,
                  key: int,
                  channel: int = NotSpecified,
                  timezone_: str = NotSpecified,
                  cycles_per_day: int = NotSpecified,
                  correction_amount: timedelta = NotSpecified,
                  ping_interval: timedelta = NotSpecified,
                  bed_time_utc: time = NotSpecified,
                  show_alternating: Optional[str] = NotSpecified,
                  ping_message: str = NotSpecified,
                  tts_value: int = NotSpecified,
                  tts_custom: Optional[str] = NotSpecified,
                  response_message: str = NotSpecified,
                  response_emotes: Optional[str] = NotSpecified,
                  color_hex: str = NotSpecified,
                  last_ping_utc: datetime = NotSpecified,
                  mute_until_utc: datetime = NotSpecified,
                  alternating_flag: bool = NotSpecified) -> Any:
     data = {}
     if channel is not NotSpecified:
         data['channel'] = channel
     if timezone_ is not NotSpecified:
         data['timezone'] = timezone_
     if cycles_per_day is not NotSpecified:
         data['cycles_per_day'] = cycles_per_day
     if correction_amount is not NotSpecified:
         data['correction_amount'] = correction_amount.total_seconds()
     if ping_interval is not NotSpecified:
         data['ping_interval'] = ping_interval.total_seconds()
     if bed_time_utc is not NotSpecified:
         data['bed_time_utc'] = bed_time_utc.isoformat()
     if show_alternating is not NotSpecified:
         data['show_alternating'] = show_alternating
     if ping_message is not NotSpecified:
         data['ping_message'] = ping_message
     if tts_value is not NotSpecified:
         data['tts_value'] = tts_value
     if tts_custom is not NotSpecified:
         data['tts_custom'] = tts_custom
     if response_message is not NotSpecified:
         data['response_message'] = response_message
     if response_emotes is not NotSpecified:
         data['response_emotes'] = response_emotes
     if color_hex is not NotSpecified:
         data['color_hex'] = color_hex
     if last_ping_utc is not NotSpecified:
         data['last_ping_utc'] = last_ping_utc.isoformat()
     if mute_until_utc is not NotSpecified:
         data['mute_until_utc'] = mute_until_utc.isoformat()
     if alternating_flag is not NotSpecified:
         data['alternating_flag'] = alternating_flag
     return self._urlopen('PUT',
                          'reminder',
                          guild=guild,
                          member=member,
                          key=key,
                          data=data)
Пример #4
0
    def _parse_datetime_time(time: datetime.time) -> str:
        time = datetime.datetime.now().replace(hour=time.hour,
                                               minute=time.minute,
                                               second=0,
                                               microsecond=0)

        if time < datetime.datetime.now():
            time += datetime.timedelta(days=1)

        return time.isoformat()
Пример #5
0
def iso_str(d: datetime.date, t: datetime.time) -> str:
    """
    Returns the ISO formatted string of data and time together.
    
    When combining, the time must be accurate to the microsecond.
    
    Parameter d: The month-day-year
    Precondition: d is a date object
    
    Parameter t: The time of day
    Precondition: t is a time object
    """
    assert isinstance(
        d,
        datetime.date), f'The paramater d must be a date object not {type(d)}.'
    assert isinstance(
        t,
        datetime.time), f'The parameter t must be a time object not {type(t)}.'
    return d.isoformat() + 'T' + t.isoformat()
  def __init__(self,
               first_name: str,
               last_name: str,
               appointment_date: date,
               appointment_time: time,
               appointment_timezone: str,
               appointment_type: str,
               scheduled_provider_npi: str,
               appointment_status: str,
               gender: str = None,
               date_of_birth: date = None,
               member_number: str = None,
               medical_member_number: str = None,
               external_appointment_id: str = None,
               appointment_location_id: str = None,
               external_last_modified_date: datetime = None,
               external_created_date: date = None,
               plan_id: int = None,
               extra_data: dict = None) -> None:

    self.first_name: str = first_name
    self.last_name: str = last_name
    self.gender: str = gender
    self.date_of_birth = date_of_birth
    self.appointment_date: date = appointment_date
    self.appointment_time: time = appointment_time.isoformat()
    self.appointment_type: str = appointment_type.lower()
    self.scheduled_provider_npi: str = scheduled_provider_npi
    self.appointment_status: str = appointment_status.lower()
    self.member_number: str = member_number
    self.medical_member_number: str = medical_member_number
    self.external_appointment_id: str = external_appointment_id
    self.appointment_location_id: str = appointment_location_id
    self.external_last_modified_date: date = external_last_modified_date
    self.external_created_date: date = external_created_date
    self.appointment_timezone = appointment_timezone
    self.plan_id = plan_id
    self.extra_data = extra_data
def time_out(v: time) -> bytes:
    return v.isoformat().encode(_client_encoding)
Пример #8
0
 def transform_python(self, value: datetime.time):
     return value.isoformat()
Пример #9
0
 def validate(cls, v: datetime.time) -> str:
     return v.isoformat("minutes")
Пример #10
0
def serialize_time(value: time) -> str:
    return value.isoformat()
Пример #11
0
def _cast_str_time(cls: Type[str], val: datetime.time, ctx):
    if ctx.time_format == 'iso':
        return cls(val.isoformat())
    else:
        return cls(val.strftime(ctx.time_format))
Пример #12
0
def convert_time(val: dt.time) -> str:
    return val.isoformat()
Пример #13
0
 def serialize(self, value: time, **options) -> str:
     return value.isoformat()
Пример #14
0
def _time(o: datetime.time, repl_ctx: context.ReplContext,
          buf: terminal.Buffer) -> None:
    buf.write("<local_time>", style.code_comment)
    buf.write(repr(o.isoformat()), style.code_string)
Пример #15
0
def _time(o: datetime.time):
    return o.isoformat()
Пример #16
0
def ts_time(val: datetime.time) -> str:
    """Used if *val* is an instance of time."""
    return val.isoformat()
def time_representer(dumper: yaml.Dumper, data: time) -> yaml.ScalarNode:
    return dumper.represent_scalar(TIME_TAG, data.isoformat())
Пример #18
0
def serialize_time(t: time) -> dict:
    return {"time": t.isoformat()}
Пример #19
0
def time_encoder(time: datetime.time):
    if time.utcoffset() is not None:
        raise ValueError("JSON can't represent timezone-aware times.")
    return time.isoformat()
Пример #20
0
def humanize_time(time_: time) -> str:
    """ Use this function for convert time to hh:mm """
    if isinstance(time_, time):
        return time_.isoformat(timespec='minutes')
Пример #21
0
def _dump_time(time: datetime.time) -> str:
    return time.isoformat()
Пример #22
0
 def to_raw(self, value: datetime.time):
     return value.isoformat() if value else None
Пример #23
0
def convert_time_in(value: datetime.time) -> str:
    """
    Converts the time value being passed into sqlite.
    """
    return value.isoformat()
Пример #24
0
def serialize(value: PyTime):
    return value.isoformat()
Пример #25
0
def convert_time_with_timezone(value: datetime.time):
    return bytearray(value.isoformat().encode())
Пример #26
0
 def dump_time(self, d: datetime.time) -> str:
     return d.isoformat()
Пример #27
0
 def serialize(obj: dt.time) -> str:
     # Format date as HH:MM:SS
     return obj.isoformat()