Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UTC option to FormatTime #1818

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sirdigbot
Copy link
Contributor

@sirdigbot sirdigbot commented Aug 11, 2022

Resolves #875

Tested with the following code and https://www.epochconverter.com/

#include <sourcemod>

public void OnPluginStart()
{
    char time[32];
    
    PrintToServer("Now: %i", GetTime());
    
    FormatTime(time, sizeof(time), "%Y-%m-%d %H:%M:%S", 0);
    PrintToServer("Local time 0: %s", time);
    
    FormatTime(time, sizeof(time), "%Y-%m-%d %H:%M:%S", 0, false); 
    PrintToServer("UTC time 0: %s", time);
    
    FormatTime(time, sizeof(time), "%Y-%m-%d %H:%M:%S");
    PrintToServer("Local time now: %s", time);
    
    FormatTime(time, sizeof(time), "%Y-%m-%d %H:%M:%S", -1, false);
    PrintToServer("UTC time now: %s", time);

    // OUTPUTS:
    // Now: 1660197444
    // Local time 0: 1970-01-01 11:00:00
    // UTC time 0: 1970-01-01 00:00:00
    // Local time now: 2022-08-11 15:57:24
    // UTC time now: 2022-08-11 05:57:24
}

@sirdigbot
Copy link
Contributor Author

I never saw it because I guess it wasn't linked to the issue, but PR #917 addresses the same thing

core/logic/smn_core.cpp Outdated Show resolved Hide resolved
@sapphonie
Copy link
Contributor

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: FormatTime() and time correcting
3 participants