Convert timestamp to date format

cin34

Member
Jan 23, 2016
32
15
58
Hello, I have a problem before formatting the last user connection that is in the timestamp to the date format in the form "H:minutes, month.day.year".
Code:
            if (ts3Functions.getClientVariableAsString(serverConnectionHandlerID, (anyID)id, CLIENT_LASTCONNECTED, &lastconnected) != ERROR_ok) {
                printf("Error getting client nickname\n");
                return;
            }

Can anyone help? Thanks. :)
 

cin34

Member
Jan 23, 2016
32
15
58
I did, but I have some warnings.

Code:
void ts3plugin_infoData(uint64 serverConnectionHandlerID, uint64 id, enum PluginItemType type, char** data) {
    char* firstconnected;
    char* lastconnected;
   
    switch(type) {
            break;
        case PLUGIN_CLIENT:

            if (ts3Functions.getClientVariableAsString(serverConnectionHandlerID, (anyID)id, CLIENT_CREATED, &firstconnected) != ERROR_ok) {
                printf("Error getting client nickname\n");
                return;
            }

            if (ts3Functions.getClientVariableAsString(serverConnectionHandlerID, (anyID)id, CLIENT_LASTCONNECTED, &lastconnected) != ERROR_ok) {
                printf("Error getting client nickname\n");
                return;
            }

            break;
        default:
            printf("Invalid item type: %d\n", type);
            data = NULL;
            return;
    }
   
    url = url_encode(uid);

    char buffer1[80];
    strftime(buffer1, 80, "%Y-%m-%d %X", firstconnected);

    char buffer2[80];
    strftime(buffer2, 80, "%Y-%m-%d %X", lastconnected);

    *data = (char*)malloc(INFODATA_BUFSIZE * sizeof(char));
    snprintf(*data, INFODATA_BUFSIZE, "\n[b]Version:[/b] %s\n[b]Connections[/b]: %s\n[b]Database ID:[/b] %s\n[b]First connect: |%s|\n[b]Last connect:[/b] %s\n[b]On ts3index:[/b] [URL=http://ts3index.com/?page=searchclient&uid=%s]%s[/URL]", version, totalconnections, dbid, buffer1, buffer2, url, uid);
    ts3Functions.freeMemory(firstconnected);
    ts3Functions.freeMemory(lastconnected);
}

1>------ Build started: Project: test_plugin, Configuration: Release x64 ------
1>plugin.c
1>plugin.c(561): warning C4133: 'function': incompatible types - from 'char *' to 'const tm *'
1>plugin.c(564): warning C4133: 'function': incompatible types - from 'char *' to 'const tm *'
1>plugin.c(515): warning C4101: 'test': unreferenced local variable
1>test_plugin.vcxproj -> D:\pluginsdk\src\x64\Release\test_plugin.dll
1>Done building project "test_plugin.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========


What have i done wrong?
 
Last edited:
Top