Created
July 19, 2012 08:55
-
-
Save georgexsh/3141684 to your computer and use it in GitHub Desktop.
simple launchy plugin, convert timestamp to date
This file contains hidden or 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
// A simple plugin, convert timestamp to date | |
// [email protected] | |
// 2008-8-8 | |
// Under WTFPL | |
#include "stdafx.h" | |
#include "LaunchyPlugin.h" | |
#include "time.h" | |
#include <sstream> | |
#ifdef _MANAGED | |
#pragma managed(push, off) | |
#endif | |
BOOL APIENTRY DllMain( HMODULE hModule, | |
DWORD ul_reason_for_call, | |
LPVOID lpReserved | |
) | |
{ | |
return TRUE; | |
} | |
#ifdef _MANAGED | |
#pragma managed(pop) | |
#endif | |
bool PluginOwnsSearch (TCHAR* txt) | |
{ | |
return false; | |
} | |
SearchResult* PluginGetIdentifiers (int* iNumResults) | |
{ | |
*iNumResults = 0; | |
return NULL; | |
} | |
TCHAR* PluginGetRegexs(int* iNumResults) | |
{ | |
*iNumResults = 1; | |
wstring regex = L"[0-9]{9,10}"; | |
return string2TCHAR(regex); | |
} | |
SearchResult* PluginUpdateSearch (int NumStrings, const TCHAR* Strings, const TCHAR* FinalString, int* NumResults) { | |
int a = 0; | |
while(*FinalString && *FinalString >= '0' && *FinalString <= '9'){ | |
a = a * 10 + *FinalString++ - '0'; | |
} | |
a += 28800; // GMT +8 timezone twake | |
time_t timep = (time_t)a; | |
struct tm tms; | |
gmtime_s(&tms, &timep); | |
int year = tms.tm_year + 1900; | |
int mon = tms.tm_mon + 1; | |
int day = tms.tm_mday; | |
int hour = tms.tm_hour; | |
int min = tms.tm_min; | |
int sec = tms.tm_sec; | |
vector<SearchResult> results; | |
wostringstream out; | |
out << year << "-" << mon << "-" << day << " "; | |
out << hour << ":" << min << ":" << sec; | |
results.push_back(makeResult(out.str(), FinalString, L"", NULL)); | |
*NumResults = 1; | |
return ResultVectorToArray(results); | |
} | |
SearchResult* PluginFileOptions (const TCHAR* FullPath, int NumStrings, const TCHAR* Strings, const TCHAR* FinalString, int* NumResults) | |
{ | |
*NumResults = 0; | |
return NULL; | |
} | |
void PluginDoAction (int NumStrings, const TCHAR* Strings, const TCHAR* FinalString, const TCHAR* FullPath) { | |
return; | |
} | |
TCHAR* PluginGetSeparator() { | |
wstring tmp = L""; | |
return string2TCHAR(tmp); | |
} | |
TCHAR* PluginGetName() { | |
wstring tmp = L"Timestamp converter plugin"; | |
return string2TCHAR(tmp); | |
} | |
TCHAR* PluginGetDescription() { | |
wstring tmp = L"Convert timestamp to date"; | |
return string2TCHAR(tmp); | |
} | |
void PluginClose() { | |
return; | |
} | |
void PluginInitialize() { | |
return; | |
} | |
void PluginSaveOptions() { | |
return; | |
} | |
void PluginCallOptionsDlg(HWND parent) { | |
return; | |
} | |
bool PluginHasOptionsDlg() { | |
return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment