Skip to content

Commit

Permalink
Merge pull request #1846 from Expensify/youssef_add_STIMESTAMP_MS
Browse files Browse the repository at this point in the history
  • Loading branch information
cead22 authored Aug 13, 2024
2 parents 8df468c + da54367 commit 72b5efa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libstuff/STime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,18 @@ timeval SToTimeval(uint64_t when) {
return {(time_t)(when / STIME_US_PER_S), (suseconds_t)(when % STIME_US_PER_S)};
}

string SCURRENT_TIMESTAMP_MS() {
uint64_t time = STimeNow();
string STIMESTAMP_MS(uint64_t time) {
uint64_t ms = (time % 1'000'000) / 1'000;
string timestamp = SUNQUOTED_TIMESTAMP(time);
char msString[5] = {0};
snprintf(msString, 5, "%03lu", ms);
return timestamp + "." + msString;
}

string SCURRENT_TIMESTAMP_MS() {
return STIMESTAMP_MS(STimeNow());
}

string SFirstOfMonth(const string& timeStamp, const int64_t& offset) {

list<string> parts = SParseList(timeStamp, '-');
Expand Down
1 change: 1 addition & 0 deletions libstuff/libstuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ string STIMESTAMP(uint64_t when);
string SUNQUOTED_CURRENT_TIMESTAMP();
string SCURRENT_TIMESTAMP();
string SCURRENT_TIMESTAMP_MS();
string STIMESTAMP_MS(uint64_t time);

// --------------------------------------------------------------------------
// Miscellaneous stuff
Expand Down

0 comments on commit 72b5efa

Please sign in to comment.