Jump to content
Sign in to follow this  
dcthehole

Epoch DLL

Recommended Posts

The purpose of the Epoch.dll to is to get the system date and time and allow arma to use it accordingly.

You can get the file here and put the .dll file in your Arma3 Steam directory.

Here is the source code (feel free to tweak as you like):

#define WIN32_LEAN_AND_MEAN
#include <time.h>
#include <windows.h>
#include <stdio.h>

BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
	break;
}
return TRUE;
}

extern "C"
{
 __declspec(dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function);
};

void __stdcall RVExtension(char *output, int outputSize, const char *function)
{
outputSize -= 1;
if (!strcmp(function,"Version")) {
	strncpy(output,"Epoch.dll Version 1.0",outputSize);
} else if(!strcmp(function,"DateTime")) {
	char text[100];
	time_t now = time(NULL);
	struct tm *t = localtime(&now);
	strftime(text, sizeof(text)-1, "%m-%d-%Y %H:%M:%S", t);
	sprintf(output, "%s", text );
} else if(!strcmp(function,"Date")) {
	char text[100];
	time_t now = time(NULL);
	struct tm *t = localtime(&now);
	strftime(text, sizeof(text)-1, "%m-%d-%Y", t);
	sprintf(output, "%s", text );
} else if(!strcmp(function,"Time")) {
	char text[100];
	time_t now = time(NULL);
	struct tm *t = localtime(&now);
	strftime(text, sizeof(text)-1, "%H:%M:%S", t);
	sprintf(output, "%s", text );
} else {
	strncpy(output,"Unknown Function!",outputSize);
}
}

The extension accepts 3 functions(DateTime,Date,Time).

Super simple to do. Here are some quick examples.

Version (Will return the version number):

diag_log text format["Version -> %1",("Epoch" callextension "Version")];
hint format["The Epoch.dll version is: %1",("Epoch" callextension "Version")];

DateTime (Returns the date and time formatted like Month-Day-Year Hour:Min:Sec):

diag_log text format["DateTime -> %1",("Epoch" callextension "DateTime")];
hint format["The date and time is: %1",("Epoch" callextension "DateTime")];

Date (Returns just the date formatted like Month-Day-Year):

diag_log text format["Date -> %1",("Epoch" callextension "Date")];
hint format["The date is: %1",("Epoch" callextension "Date")];

Time (Returns just the time formatted like Hour:Min:Sec):

diag_log text format["Time -> %1",("Epoch" callextension "Time")];
hint format["The time is: %1",("Epoch" callextension "Time")];

Let me know what you guys think.

Edited by dcthehole
Add some examples

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×