Author Topic: Date  (Read 1424 times)

ARSEnic.

  • Newbie
  • *
  • Posts: 47
  • Karma: +17/-15
  • Hell o!
    • View Profile
Date
« on: March 09, 2017, 02:39:25 pm »
I made this because I wanted to get the date and day of the week individually which GetFullTime() and GetDate() can't seem to get.



Code: [Select]
function GetDate( Part )
{
Part = Part.tolower();
if( Part == "date" )
{
local Month = GetTok( GetFullTime(), " ", 2 );
local Day = GetTok( GetFullTime(), " ", 3 );
local Year = GetTok( GetFullTime(), " ", 5 );

if( Month == "Jan" ) Month = "January";
if( Month == "Feb" ) Month = "February"
if( Month == "Mar" ) Month = "March"
if( Month == "Apr" ) Month = "April"
if( Month == "May" ) Month = "May"
if( Month == "Jun" ) Month = "June"
if( Month == "Jul" ) Month = "July"
if( Month == "Aug" ) Month = "August"
if( Month == "Sep" ) Month = "September"
if( Month == "Oct" ) Month = "October"
if( Month == "Nov" ) Month = "November"
if( Month == "Dec" ) Month = "December"

return Day + " " + Month + " " + Year;
}
else if( Part == "day" )
{
local Day = GetTok( GetFullTime(), " ", 1 );

if( Day == "Mon" ) Day = "Monday";
if( Day == "Tue" ) Day = "Tuesday"
if( Day == "Wed" ) Day = "Wednesday"
if( Day == "Thu" ) Day = "Thursday"
if( Day == "Fri" ) Day = "Friday"
if( Day == "Sat" ) Day = "Saturday"
if( Day == "Sun" ) Day = "Sunday"
return Day;
}
else if( Part == "time" )
{
local Time = GetTok( GetFullTime(), " ", 4 );

return Time;
}
else return false;
}



Usage:
GetDate("date");
Which returns Day, Month and the Year
For example, 9 March 2017

GetDate("day");
Which returns the day of the week in full form
For example, Thursday

GetDate("time");
Which returns the Hour:Minute:Second
For example, 12:34:56



Note: This might not be the most efficient way to do this but i can't think of any other way so...

LUmtap

  • Newbie
  • *
  • Posts: 45
  • Karma: +4/-8
  • Check my YT channel!
    • View Profile
    • My YouTube channel -->> LUmtap
Re: Date
« Reply #1 on: March 10, 2017, 02:37:41 am »
dafak i put date in google images and show a fruit shit lol

Vortrex

  • Full Member
  • ***
  • Posts: 267
  • Karma: +54/-73
    • View Profile
Re: Date
« Reply #2 on: March 10, 2017, 12:41:48 pm »
Note: This might not be the most efficient way to do this but i can't think of any other way so...

Here's another way to do it, too ...
Code: [Select]
Months <- [ "January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December" ];
WeekDays <- [ "Sunday" , "Monday" , "Tuesday" , "Wednesday" , "Thursday" , "Friday" , "Saturday" ];

function GetDate ( part ) {

local current = date ( );

switch ( part.tolower ( ) ) {

case "date":
return current.day + " " + Months [ current.month ] + " " + current.year;

case "day":
return WeekDays [ current ];

case "time":
return current.hour + ":" + current.min + ":" + current.sec;

default:
return GetDate ( "day" ) + ", " + GetDate ( "date" ) + " at " + GetDate ( "time" );

}

return

}

ARSEnic.

  • Newbie
  • *
  • Posts: 47
  • Karma: +17/-15
  • Hell o!
    • View Profile
Re: Date
« Reply #3 on: March 11, 2017, 04:17:26 am »
oh nice, works so much better than mine thanks :)

 

© Liberty Unleashed Team.