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

New built-in functions for working with unix time [CORE4406] #4728

Open
firebird-automations opened this issue Apr 28, 2014 · 0 comments
Open

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @doychin

It will be great if there is a function from_unixtime that will convert unix time stamp in milliseconds to firebird timestamp.

This is a similar function for linux that returns string:

------------------------------
#⁠include <stdio.h>
#⁠include <time.h>
#⁠include <stdlib.h>

char* from_unixtime(long long int*);

char* from_unixtime(t)
long long int *t;
{
char* res = (char*)malloc(32);

long milis = *t % 1000;
long tt = *t / 1000;

char tmp[32];
strftime(tmp, 32, "%Y-%m-%d %H:%M:%S", localtime(&tt));

sprintf(res, "%s:%d", tmp, milis);

return res;
}
---------------------------------
DECLARE EXTERNAL FUNCTION FROM_UNIXTIME
BIGINT
RETURNS CSTRING(100) FREE_IT
ENTRY_POINT 'from_unixtime' MODULE_NAME 'unixTime';
---------------------------------

There is similar function in MySQL.

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

No branches or pull requests

1 participant