Last active
November 9, 2018 08:55
-
-
Save fsans/3303058 to your computer and use it in GitHub Desktop.
FMTimeHiRes() plugin función
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* FMTimeHiRes.cpp | |
* PlugInTemplate | |
* | |
* Created by Francesc Sans on 16/07/12. | |
* Copyright 2012 Network BCN Software. All rights reserved. | |
* | |
* FMTimeHiRes({format}) | |
* | |
* Returns Timestamp to microseconds precisión | |
* | |
* | |
*/ | |
#include <time.h> | |
#pragma mark DCBox_GetTimeHiRes | |
FMX_PROC(fmx::errcode) DCBox_GetTimeHiRes(short funcId, const fmx::ExprEnv& environment, const fmx::DataVect& dataVect, fmx::Data& result) | |
{ | |
#pragma unused(funcId,environment) | |
fmx::errcode err = 0; | |
fmx::FixPtAutoPtr epoch; | |
fmx::TextAutoPtr tempText; | |
fmx::TextAutoPtr resultText; | |
struct timeval tv; | |
gettimeofday(&tv, NULL); | |
if( dataVect.Size() > 0 ) | |
{ | |
//We have at least one parameter. Read it and return correct information. | |
const fmx::Text& parameter1 = dataVect.AtAsText(0); | |
if( tempText->Assign(""), *tempText == parameter1 ) | |
{ | |
// defaul format option | |
epoch->AssignDouble ( double(tv.tv_sec + tv.tv_usec/1000000.0) ); | |
result.SetAsNumber( *epoch ); | |
} | |
else if( tempText->Assign("epoch"), *tempText == parameter1 ) | |
{ | |
// epoch format option, same as default | |
epoch->AssignDouble ( double(tv.tv_sec + tv.tv_usec/1000000.0) ); | |
result.SetAsNumber( *epoch ); | |
} | |
else if( tempText->Assign("UTC"), *tempText == parameter1 ) | |
{ | |
// ( TO DO ) UTC format option | |
epoch->AssignDouble ( double(tv.tv_sec + tv.tv_usec/1000000.0) ); | |
result.SetAsNumber( *epoch ); | |
} | |
else if( tempText->Assign("local"), *tempText == parameter1 ) | |
{ | |
// ( TO DO ) Local format option | |
epoch->AssignDouble ( double(tv.tv_sec + tv.tv_usec/1000000.0) ); | |
result.SetAsNumber( *epoch ); | |
} | |
} | |
return err; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment