import {httpUtil} from "./httpUtil"
import request from "./request"
import {heightLight} from "./heightLignt"
import {pageUtil} from "./pageUtil"
import { domainChagneUtil } from "./domainChangeUtil"
import { standardUtil } from "./standardUtil"

export {
    httpUtil,
    request,
    heightLight,
    pageUtil,
    domainChagneUtil,
    standardUtil
}

export const timestampToTime = (timestamp:any) => {
    timestamp = timestamp ? timestamp : null;
    let date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    let Y = date.getFullYear() + '-';
    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
    let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
    let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
    let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
    return Y + M + D + h + m + s;
}


export function compare(property: any){
    return function(a: any, b: any){
        var value1 = a[property];
        var value2 = b[property];
        return value2 - value1;
    }
}


export function timeCompare(property: any){
    return function(a: any, b: any){
        var value1 = new Date(a[property]).getTime();
        var value2 = new Date(b[property]).getTime();
        return value2 - value1;
    }
}