@juniorfixhow/durationjs
v1.0.1
Published
This package is to check the time difference.
Downloads
12
Maintainers
Readme
��#� �I�n�s�t�a�l�l�a�t�i�o�n�
�
�n�p�m� �i� �@�j�u�n�i�o�r�f�i�x�h�o�w�/�d�u�r�a�t�i�o�n�j�s�
�
�
�
�#� �U�s�a�g�e�
�
�c�o�n�s�t� �{� �c�h�e�c�k�T�i�m�e�S�i�n�c�e�,� �t�i�m�e�R�e�m�a�i�n�i�n�g�,� �c�o�u�n�t�D�o�w�n� �}� �=� �r�e�q�u�i�r�e�(�"�@�j�u�n�i�o�r�f�i�x�h�o�w�/�d�u�r�a�t�i�o�n�j�s�"�)�;� �/�/�c�o�m�m�o�n�j�s�
�
�<�b�r�>�
�
�i�m�p�o�r�t� �{� �c�h�e�c�k�T�i�m�e�S�i�n�c�e�,� �t�i�m�e�R�e�m�a�i�n�i�n�g�,� �c�o�u�n�t�D�o�w�n� �}� �f�r�o�m� �"�@�j�u�n�i�o�r�f�i�x�h�o�w�/�d�u�r�a�t�i�o�n�j�s�"�;� �/�/�m�o�d�u�l�e�
�
�
�
�#� �c�h�e�c�k�T�i�m�e�S�i�n�c�e�
�
�T�h�i�s� �f�u�n�c�t�i�o�n� �c�h�e�c�k�s� �f�o�r� �t�h�e� �t�i�m�e� �d�i�f�f�e�r�e�n�c�e� �b�e�t�w�e�e�n� �t�h�e� �c�u�r�r�e�n�t� �d�a�t�e�-�t�i�m�e� �a�n�d� �t�h�e� �p�a�s�t�.�
�
�
�
�c�o�n�s�t� �p�a�s�t� �=� �c�h�e�c�k�T�i�m�e�S�i�n�c�e�(�n�e�w� �D�a�t�e�(�"�2�0�2�4�-�0�4�-�1�1�T�0�9�:�2�1�:�0�4�.�4�5�9�Z�"�)�)�;�
�
�<�b�r�>�
�
�c�o�n�s�o�l�e�.�l�o�g�(�p�a�s�t� �+� �'� �a�g�o�'�)�
�
�
�
�#� �t�i�m�e�R�e�m�a�i�n�i�n�g�
�
�T�h�i�s� �f�u�n�c�t�i�o�n� �c�h�e�c�k�s� �f�o�r� �t�h�e� �t�i�m�e� �d�i�f�f�e�r�e�n�c�e� �b�e�t�w�e�e�n� �t�h�e� �f�u�t�u�r�e� �d�a�t�e�-�t�i�m�e� �a�n�d� �t�h�e� �c�u�r�r�e�n�t� �o�n�e�.�
�
�<�b�r�>�
�
�c�o�n�s�t� �t�i�m�e� �=� �n�e�w� �D�a�t�e�(�n�e�w� �D�a�t�e�(�)�.�s�e�t�H�o�u�r�s�(�n�e�w� �D�a�t�e�(�)�.�g�e�t�H�o�u�r�s�(�)�+�5�)�)�;� �/�/�t�h�i�s� �i�s� �s�u�p�p�o�s�e�d� �t�o� �b�e� �t�h�e� �f�u�t�u�r�e� �d�a�t�e�-�t�i�m�e�.�
�
�<�b�r�>�
�
�c�o�n�s�t� �f�u�t�u�r�e� �=� �t�i�m�e�R�e�m�a�i�n�i�n�g�(�t�i�m�e�)�
�
�<�b�r�>�
�
�c�o�n�s�o�l�e�.�l�o�g�(�f�u�t�u�r�e� �+� �'� �r�e�m�a�i�n�i�n�g�'�)�
�
�
�
�#� �c�o�u�n�t�D�o�w�n�
�
�T�h�i�s� �f�u�n�c�t�i�o�n� �c�o�u�n�t�s� �d�o�w�n� �f�r�o�m� �a� �f�u�t�u�r�e� �d�a�t�e� �a�n�d� �s�t�o�p�s� �w�h�e�n� �i�t� �r�e�a�c�h�e�s� �t�h�e� �c�u�r�r�e�n�t� �d�a�t�e�-�t�i�m�e�
�
�<�b�r�>�
�
�
�
�#�#�#� �E�x�a�m�p�l�e� �U�s�a�g�e�
�
�
�
��
�`�j�a�v�a�s�c�r�i�p�t�
�
�i�m�p�o�r�t� �R�e�a�c�t�,� �{� �u�s�e�E�f�f�e�c�t�,� �u�s�e�S�t�a�t�e� �}� �f�r�o�m� �'�r�e�a�c�t�'�;�
�
�
�
�c�o�n�s�t� �Y�o�u�r�C�o�m�p�o�n�e�n�t� �=� �(�)� �=�>� �{�
�
� � �c�o�n�s�t� �[�f�o�r�m�a�t�t�e�d�T�i�m�e�,� �s�e�t�F�o�r�m�a�t�t�e�d�T�i�m�e�]� �=� �u�s�e�S�t�a�t�e�(�'�'�)�;�
�
�
�
� � �u�s�e�E�f�f�e�c�t�(�(�)� �=�>� �{�
�
� � � � �c�o�n�s�t� �t�i�m�e�r� �=� �c�o�u�n�t�D�o�w�n�(�'�2�0�2�4�-�0�4�-�1�3�T�1�2�:�0�0�:�0�0�'�)�;�
�
�
�
� � � � �c�o�n�s�t� �i�n�t�e�r�v�a�l�I�d� �=� �s�e�t�I�n�t�e�r�v�a�l�(�(�)� �=�>� �{�
�
� � � � � � �c�o�n�s�t� �t�i�m�e� �=� �t�i�m�e�r�.�g�e�t�F�o�r�m�a�t�t�e�d�T�i�m�e�(�)�;�
�
� � � � � � �s�e�t�F�o�r�m�a�t�t�e�d�T�i�m�e�(�t�i�m�e�)�;�
�
� � � � �}�,� �1�0�0�0�)�;�
�
�
�
� � � � �/�/� �C�a�l�l� �t�h�e� �s�t�o�p� �m�e�t�h�o�d� �a�n�d� �c�l�e�a�r� �t�h�e� �i�n�t�e�r�v�a�l� �w�h�e�n� �t�h�e� �c�o�m�p�o�n�e�n�t� �u�n�m�o�u�n�t�s�
�
� � � � �r�e�t�u�r�n� �(�)� �=�>� �{�
�
� � � � � � �t�i�m�e�r�.�s�t�o�p�(�)�;�
�
� � � � � � �c�l�e�a�r�I�n�t�e�r�v�a�l�(�i�n�t�e�r�v�a�l�I�d�)�;�
�
� � � � �}�;�
�
� � �}�,� �[�]�)�;�
�
�
�
� � �r�e�t�u�r�n� �<�d�i�v�>�{�f�o�r�m�a�t�t�e�d�T�i�m�e�}�<�/�d�i�v�>�;�
�
�}�;�