File: //usr/lib/python3/dist-packages/mercurial/dirstateutils/__pycache__/timestamp.cpython-310.pyc
o
�]Lb} � @ sn d dl mZ d dlZd dlZd dlZddlmZ dZejG dd� de ��Z
dd � Zd
d� Zdd
� Z
dd� ZdS )� )�absolute_importN� )�errori���c s0 e Zd ZdZ� fdd�Zdd� Zdd� Z� ZS )� timestampa�
A Unix timestamp with optional nanoseconds precision,
modulo 2**31 seconds.
A 3-tuple containing:
`truncated_seconds`: seconds since the Unix epoch,
truncated to its lower 31 bits
`subsecond_nanoseconds`: number of nanoseconds since `truncated_seconds`.
When this is zero, the sub-second precision is considered unknown.
`second_ambiguous`: whether this timestamp is still "reliable"
(see `reliable_mtime_of`) if we drop its sub-second component.
c s* |\}}}|t @ ||f}tt| ��| |�S )N)� rangemask�superr �__new__)�cls�value�truncated_seconds�subsec_nanos�second_ambiguous�� __class__� �C/usr/lib/python3/dist-packages/mercurial/dirstateutils/timestamp.pyr $ s
ztimestamp.__new__c C �
t �d���Nz+timestamp should never be compared directly�r �ProgrammingError��self�otherr r r �__eq__) � �ztimestamp.__eq__c C r r r r r r r �__gt__. r ztimestamp.__gt__)�__name__�
__module__�__qualname__�__doc__r r r �
__classcell__r r r r r s
r c C sH | � � \}}ztt�|��W t�|� | �|� S t�|� | �|� w )z~return a timestamp for "now" in the current vfs
This will raise an exception if no temporary files could be created.
)�mkstemp�mtime_of�os�fstat�close�unlink)�vfs�tmpfd�tmpnamer r r �
get_fs_now4 s
�r* c C s t �td�S )z4
Returns the `timestamp` at the Unix epoch.
)r r )�tupler r r r r r �zeroA s r, c C sR z| j }W n ty | tj }d}Y n
w td�}|| }|| }t||df�S )zo
Takes an `os.stat_result`-like object and returns a `timestamp` object
for its modification time.
r g e��AF)�st_mtime_ns�AttributeError�stat�ST_MTIME�intr )�stat_result�nanos�secsr �billionr r r r"