312 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
8
votes
1
answer
257
views
What are all the various reasons for `mktime()` and `timegm()` to return `(time_t)-1`?
Various existing posts (especially non-C ones) ask why mktime() or timegm() return (time_t)-1 yet only 1 or 2 reasons usually appears: result is out of time_t range or negative.
What are all the C ...
chux's user avatar
- 158k
0
votes
1
answer
47
views
Running the app with custom downloaded glibc gives seg fault [duplicate]
I downloaded custom glibc and then compiled using g++ dt.cpp -std=c++11 -Wl,-rpath "/opt/glibc-2.28/lib", but it gives seg fault
#include <iostream> ...
1
vote
1
answer
106
views
Why does converting a `time_t` via `localtime()` and `mktime()` sometimes not return the same value?
I was trying to round-trip a time_t through struct tm *localtime(time_t t) and then time_t mktime(struct tm *tm).
#include <stdbool.h>
#include <stdio.h>
#include <time.h>
bool ...
5
votes
1
answer
279
views
mktime() call never returns. Library bug?
Considering local time.
In testing some time code with the potential hundreds of time zones, some of them result in a mktime() call that never returns for select values!
Detail: Code never returns ...
chux's user avatar
- 158k
0
votes
1
answer
224
views
mktime resulting in OverflowError: mktime argument out of range
When attempting to get a time using mktime, I get a overflow exception. This occurs on a Debian docker image, but not on my host machine:
docker pull python:3.9.7
https://hub.docker.com/layers/...
1
vote
1
answer
107
views
C++ - Running same mktime() logic in 2 different ways giving unexpected result
I am converting a time in string to long time using strptime() and mktime. Strangely, using the same code in two different ways is giving different results. The values of struct tm is same in both the ...
0
votes
1
answer
142
views
mktime causing overflowError due to daylight savings time
I'm currently getting an Overflow error on the following code when daylight savings is set to true. I've tried a number of date/time combinations and it appears to only be the 9th parameter ("...
0
votes
1
answer
381
views
Parsing datetime string with UTC offset to time_t
This question is hinted at in this one, but the answer to that question doesn't answer this question at all, and I've conflicting suggestions and hints scattered around.
My problem is relatively ...
0
votes
1
answer
316
views
Converting c++ tm struct and mktime to C#
I'm converting some c++ to c# code. I cannot reproduce equivalent values when converting from the tm struct and mktime() to c#.
Example:
Both versions use the same values:
int year = 2022;
int month = ...
1
vote
3
answers
648
views
How can I convert the day of the year (365 days) equivalent date December 31
how can i use the c++ library such as mktime() to convert day to dates instead of making my own algorithm
1
vote
1
answer
160
views
mkTime() function does not pick correct timezone c++
I am getting an input date from user and convert it into tm struct, (setting is_dst, timezone and gmtoff parameters of tm struct using local time), but when I am using mkTime to get epoch value it ...
0
votes
1
answer
604
views
Get File's Epoch timestamp, convert to DateTime, to string, and then to the identical epoch float with microsecond precision
I want to take a file's epoch timestamp float (e.g., "1661796943.8816772" from "os.stat(__file__).st_mtime"), and convert that float to what I think is called a DateTime string, ...
0
votes
0
answers
314
views
mktime returning the wrong time
I have two functions for creating a date string, and parsing a date string. The creation works, but the parser seems to add 5 hours to the time. For context, my time zone is EST, 5 hours behind GMT. ...
0
votes
1
answer
201
views
Month auto increment using mktime and timegm functions in C++
I'd like to convert a string date (UTC) to a timestamp using C++.
It works fine except for the month, which is auto incremented by one.
If the string is 20221222074648, for 2022年12月22日 07:46:48, the ...
1
vote
1
answer
1k
views
How to get local time in seconds (unix epoch)?
I am trying to get the local time in seconds (unix epoch) when a timezone is set.
For e.g.
1643371200 is 2022年01月28日 12:00:00 with UTC0
this can be read via gettimeofday(tv, NULL) as seconds with the ...