o
    -g                     @   sh   d dl mZ d dlmZmZ d dlmZ d dlZd dlZddlm	Z	 ddl
mZmZ G dd	 d	e	ZdS )
    )timegm)datetime	timedelta)timezoneN   )MutableDate)parse_date_and_formulaparse_js_datec                   @   s   e Zd ZdZdd Zedd Zedd Zedd	 Zed$ddZ	d%ddZ
dd Zdd Zdd Zdd Zd%ddZdd Zdd Zdd Zd d! Zd"d# ZdS )&Momentz&A class to abstract date difficulties.c                 G   s   t | \}}|| _|| _d S N)r   _date_formula)selfargsdateformula r   L/var/www/html/django-vendor/venv/lib/python3.10/site-packages/moment/core.py__init__   s   
zMoment.__init__c                 C   s   t  }d}| ||S )z*Create a moment with the current datetime.%Y-%m-%dT%H:%M:%S)r   nowclsr   r   r   r   r   r      s   
z
Moment.nowc                 G   s&   t | \}}td|}| ||S )z Create a moment from a UTC date.UTC)r   pytzr   localize)r   r   r   r   r   r   r   utc   s   
z
Moment.utcc                 C   s"   t dt }d}| ||S )zUTC equivalent to now.r   r   )r   r   r   r   utcnowr   r   r   r   r   "   s   
zMoment.utcnowFc                 C   s^   |rt j}nt j}z||}W n ty   ||d }Y nw |r(|jtjd}d}| ||S )z$Create a date from a Unix timestamp.i  tzinfor   )r   utcfromtimestampfromtimestamp
ValueErrorreplacer   r   )r   	timestampr   funcr   r   r   r   r   unix)   s   
zMoment.unixNc                 C   sd   |st t| j | _| S zt|| j| _W | S  ty1   | jj	t|d| _Y | S w )z3Explicitly set the time zone you want to work with.r   )
r   r!   r   r   	timetupler   r   	normalizer"   r#   )r   zoner   r   r   locale=   s   zMoment.localec                 C   sT   | j }z"ztt||}W n   t||}Y W || _ | S W || _ | S || _ w )zz
        Change the time zone and affect the current moment's time. Note, a
        locality must already be set.
        )r   timesto_localto_universal)r   r)   r   r   r   r   r   H   s   zMoment.timezonec                 C   sf   d|v r1| j }d|  krdksn d|  krdkr!n nd}n
g d|d d	  }|d|}|S )
z/Check to see if a suffix is need for this date.z%^            th)stndrd
   r   )dayr#   )r   r   r7   suffixr   r   r   _check_for_suffixV   s   .zMoment._check_for_suffixc                 C   s   t |}| |}| j|S )z%Display the moment in a given format.)r	   r9   r   strftimer   r   r   r   r   formatb   s   
zMoment.formatc                 C   s   |  |}| j|S )z4Takes a Pythonic format, rather than the JS version.)r9   r   r:   r;   r   r   r   r:   h   s   
zMoment.strftimec                 C   s   | | S )z&Return the difference between moments.r   )r   momentmeasurementr   r   r   diffm      zMoment.diffc                 C   s   | j S )z#Return the datetime representation.)r   r   r   r   r   doneq   s   zMoment.donec                 C   s   t | j}| j|_|S )z%Return a clone of the current moment.)r
   r   r   )r   cloner   r   r   rC   u   s   
zMoment.clonec                 C   s   |   S )zSame as clone.)rC   rA   r   r   r   copy{   r@   zMoment.copyc                 C   s"   | j d ur| j d}d| S dS )Nr   z<Moment(%s)>z<Moment>)r   r:   )r   	formattedr   r   r   __repr__   s   
zMoment.__repr__c                 C   s*   | j d}tdtt d }|| S )Nr   z
{0:+06.2f}i  )r   r:   strr<   floatr   )r   rE   tzr   r   r   __str__   s   zMoment.__str__)Fr   )__name__
__module____qualname____doc__r   classmethodr   r   r   r&   r*   r   r9   r<   r:   r?   rB   rC   rD   rF   rJ   r   r   r   r   r
      s,    




r
   )calendarr   r   r   timer   r   r+   r   r   parser   r	   r
   r   r   r   r   <module>   s    