package fanch.multijeu.common.utils;

public class TimeUtils {

    public static double time()
    {
        return usToS(timeUs());
    }

    public static long timeUs()
    {
        return System.currentTimeMillis();
    }

    public static long timeMs()
    {
        return System.currentTimeMillis()/1000;
    }

    private static double usToS(long d)
    {
        return ((double)d)/1000;
    }

    public static class TimeInterval
    {
        protected long last;

        public TimeInterval()
        {
            last=timeUs();
        }

        public long tickUs()
        {
            long c = timeUs() - last;
            last=c;
            return c;
        }

        public double tick()
        {
            return usToS(tickUs());
        }

    }

}
