package com.hjx.miaohongentry.util;

import android.content.Context;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by l on 2018/2/6.
 */

public class StatisUtils {

    public static void addTotalNum(Context context){
        int num = SpUtils.getInt(context,Constants.SP_STATIS_WRITE_TOTAL,0);
        num ++;
        SpUtils.putInt(context,Constants.SP_STATIS_WRITE_TOTAL,num);
    }

    public static int getTotalNum(Context context){
        int num =  SpUtils.getInt(context,Constants.SP_STATIS_WRITE_TOTAL,0);
        return num;
    }

    public static void setToday(Context context){
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date now = new Date();
        String now_date = format.format(now);
        SpUtils.putString(context,Constants.SP_STATIS_DATE_TODAY,now_date);
    }

    public static boolean isToday(Context context){
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Date now = new Date();
        String now_date = format.format(now);
        String sp_today = SpUtils.getString(context,Constants.SP_STATIS_DATE_TODAY,"");
        if(now_date.equals(sp_today)){
            return true;
        }else{
            return false;
        }
    }

    public static int getTodayNum(Context context){
        int num =  SpUtils.getInt(context,Constants.SP_STATIS_WRITE_NUM_TODAY,0);
        return num;
    }

    public static long getTodayTime(Context context){
        long time =  SpUtils.getLong(context,Constants.SP_STATIS_WRITE_TIME_TODAY,0);
        return time;
    }

    public static void setTodayTime(Context context, long time){
        SpUtils.putLong(context,Constants.SP_STATIS_WRITE_TIME_TODAY,time);
    }

    public static void setTodayNum(Context context, int num){
        SpUtils.putInt(context,Constants.SP_STATIS_WRITE_NUM_TODAY,num);
    }

    public static void setEnterMiaohongTime(Context context,long mills){
        SpUtils.putLong(context,Constants.SP_STATIS_ENTER_APP_TIMR,mills);
    }

    public static long getEnterMiaohongTime(Context context){
        long mills =  SpUtils.getLong(context,Constants.SP_STATIS_ENTER_APP_TIMR,0);
        return mills;
    }
}
