Snippets

Sk Some Time Functions

Created by Sk NA last modified
	

    *****************************************(Some Time Functions)************************************************
    Created By Sk.
    function GetTime(a = time())
    {
    local b = date(a),hour = b.hour,mint = b.min,sec = b.sec;
    return format("%02d:%02d:%02d",hour,mint,sec);
    }
    function GetDate(a = time())
    {
    local b = date(a),day = b.day,month = b.month+1,year = b.year;
    return format("%02d-%02d-%i",day,month,year);
    }
    function GetFullTime(a = time())
    {
    local b = date(a),wday = b.wday,month = b.month,day = b.day,year = b.year;
    local function Week(d)
    {
            switch(d)
            {
                    case 0: return "Sunday";
                    case 1: return "Monday";
                    case 2: return "Tuesday";
                    case 3: return "Wednesday";
                    case 4: return "Thursday";
                    case 5: return "Friday";
                    case 6: return "Saturday";
            }
    };
    local function Month(d)
    {
            switch(d)
            {
                    case 1: return "January";
                    case 2: return "February";
                    case 3: return "March";
                    case 4: return "April";
                    case 5: return "May";
                    case 6: return "June";
                    case 7: return "July";
                    case 8: return "August";
                    case 9: return "September";
                    case 10: return "October";
                    case 11: return "November";
                    case 12: return "December";
            }
    };
    //return format("%.3s %.3s %02d %s %i",Week(wday),Month(month+1),day,GetTime(a),year) // in 0.3
    return format("%s, %s %02d, %i, %s",Week(wday),Month(month+1),day,year,GetTime(a)); // in 0.4
    }
    Hope you like them.
    Credits [VU_T]Sk aka Sk.

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.