Browse Source

Added getTimeFormat().

release/0.19
JustinAJ 10 years ago
parent
commit
1339e67021
  1. 9
      Jupiter/Functions.c
  2. 12
      Jupiter/Functions.h
  3. BIN
      Release/Jupiter.lib

9
Jupiter/Functions.c

@ -542,15 +542,18 @@ char *makestr(const char *str)
} }
char *getTime() char *getTime()
{
return getTimeFormat("%a %b %d %H:%M:%S %Y %Z");
}
char *getTimeFormat(const char *format)
{ {
time_t rawtime = time(0); time_t rawtime = time(0);
static char rtime[256]; static char rtime[256];
strftime(rtime, sizeof(rtime), "%a %b %d %H:%M:%S %Y %Z", localtime(&rawtime)); strftime(rtime, sizeof(rtime), format, localtime(&rawtime));
return rtime; return rtime;
} }
/** Character to integer conversion table */ /** Character to integer conversion table */
const unsigned char baseTable[] = const unsigned char baseTable[] =

12
Jupiter/Functions.h

@ -285,17 +285,27 @@ JUPITER_API bool containsSymbol(const char *str, char c);
JUPITER_API char *makestr(const char *str); JUPITER_API char *makestr(const char *str);
/** /**
* @brief returns the current time in a string format. * @brief Returns the current time in a string format.
* This will vary depending on locale. * This will vary depending on locale.
* Format: Day_of_week Month Day hh:mm:ss Year Timezone. * Format: Day_of_week Month Day hh:mm:ss Year Timezone.
* Example 1: Sun Aug 18 13:52:21 2013 EST * Example 1: Sun Aug 18 13:52:21 2013 EST
* Example 2: Thu Nov 14 03:52:57 2013 Eastern Standard Time * Example 2: Thu Nov 14 03:52:57 2013 Eastern Standard Time
* Exmaple 3: Sun Nov 17 15:06:19 2013 Tokyo Standard Time * Exmaple 3: Sun Nov 17 15:06:19 2013 Tokyo Standard Time
* This is the same as getTimeFormat("%a %b %d %H:%M:%S %Y %Z").
* *
* @return A string containing the time in the format specified above. * @return A string containing the time in the format specified above.
*/ */
JUPITER_API char *getTime(); JUPITER_API char *getTime();
/**
* @brief Returns the current time in a string format, based on an input format.
* Format specifiers are the same as strftime().
*
* @param format String denoting the desired format of the output string.
* @return A string containing the time in the format specified above.
*/
JUPITER_API char *getTimeFormat(const char *format);
/** /**
* @brief Gets the next power of 2 after a specified number. * @brief Gets the next power of 2 after a specified number.
* *

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save