import React, { useEffect, useState } from 'react';
import { Icons, TwoLine, View } from 'rn-arb-foundation';
import moment from 'moment';
import { store } from '@arb/store/ConfigureStore';
const DRAW_DURATION = 7 * 24 * 60 * 60;
const DAY_SECONDS = 24 * 60 * 60;
const Counter = () => {
const hassadDrawDate = store.getState().configs?.hassadDrawDate;
const now = moment();
const hassadDate = moment(hassadDrawDate, 'MM-DD-YYYY').startOf('day');
const hassadTillNow = Math.abs(now.diff(hassadDate, 'seconds'));
const remainingDuration = Math.abs(DRAW_DURATION - hassadTillNow);
const isMoreThanDuration = hassadTillNow / DRAW_DURATION >= 1;
const secondsToAdd = (DRAW_DURATION - remainingDuration % DRAW_DURATION) % DRAW_DURATION;
const nextHassadDateInSeconds = now.clone().add(secondsToAdd, 'seconds');
const nextHassadDate = moment(nextHassadDateInSeconds);
const isToday = () => secondsToAdd <= DAY_SECONDS;
const calculateTime = (remainingSeconds) => {
return isToday()
? 'Today'
: moment.duration(remainingSeconds, 'seconds').toFormat('d[d] : h[h] : m[m]