ctime Questions
3
Solved
I know there's a way to modify both 'modification' (mtime) and 'last access' (atime) time properties of a given file in Unix System by using "touch" command.
But I'm wondering whether there exists ...
3
Solved
I am writing a simple logging class in C++ for learning purposes. My code contains a function that returns a string of today's date. However, I get a compiler error whenever 'localtime' is called.
...
8
Solved
I'm trying to generate a random int that is either 0 or 1 in C++. Right now, I receive a 0 every time I run this code, and I'm not sure why. What's the problem here?
#include <ctime>
#...
1
Solved
I fully expect this to be closed within a day or two since it's a kinda subjective topic, but here goes anyway: Why does it take at least 5 lines of code to get the date/time in C++?
This was one ...
Tornado asked 28/12, 2019 at 10:18
3
Solved
Consider the following C++ code
#include <ctime>
#include <iostream>
int main()
{
std::time_t now = std::time(nullptr);
struct tm local = *std::localtime(&now);
struct tm gm = ...
1
Solved
I have a script regularly appending to a log file. When I use entr (discovered here) to monitor that log file, and I then touch the log, everything works fine, but when the script appends to the fi...
3
Solved
I'm trying to compile a project on the command line on Maverick 10.9. The project compiles perfectly on Linux. Apparently, there seems to be an issue with ctime on MacOSX. The errors are
$ make
Co...
4
Solved
I'm trying to set the filesystem creation time for a file on Mac OS using a ruby script.
On Mac OS X the 'ctime' represents the last time of inode modification rather than the file creation time, ...
Dharma asked 8/12, 2011 at 3:16
4
I have one struct tm.
And I need to add some fixed interval (given in xx years, xx months, xx days)
to the tm struct.
Is there any standard function to do this?
The compiler I use is MSVC 2005 on ...
5
Solved
I have a large project about static source code analysis, and everything compiles successfully, except for one thing. I have provided the error message in the title. The point that confuses me is t...
Pastis asked 25/11, 2012 at 12:8
9
Solved
I have an issue with inserting time in a text file. I use the following code and i get |21,43,1,3,10,5| Wed Feb 01 20:42:32 2012 which is normal but what i WANT TO DO is place the time before the n...
Ruder asked 1/2, 2012 at 19:1
3
Solved
How can i count the millisecond a certain function (called repeatedly) takes ?
I thought of:
CTime::GetCurrentTM() before,
CTime::GetCurrentTM() after,
And then insert the result to CTimeSpan dif...
3
Solved
I was expecting the following code should print different time stamps t1 and t2, however the result shows t1 and t2 are the same. Where did I make the mistake?
#include<iostream>
#include&l...
2
Solved
I have variable tmit: long tmit;. I got error in this code:
printf("Time: %s",ctime(&tmit));
And error say: Cannot convert 'long int*' to 'const time_t* {aka const long long int*}' for argum...
2
Solved
For measuring execution time of a function, I can use both. But what is the difference between using <chrono> and <ctime>? Should I prefer one instead of another?
Ungrudging asked 18/3, 2016 at 22:30
2
Solved
How do I get system up time since the start of the system? All I found was time since epoch and nothing else.
For example, something like time() in ctime library, but it only gives me a value of s...
1
Solved
I am trying to get the running time of Insertion Sort Algorithm. MSDN said that using CTime could get the Elapsed Time. But I tried many times and always got zero. I thought it is impossible that t...
Vday asked 21/9, 2014 at 0:30
2
Solved
Consider these two ways to get an epoch time from a date formatted as a string:
#include <iostream>
int main() {
struct tm tm_init = {0};
strptime("2012-10-26 16:00", "%Y-%m-%dT %H:%M", &...
3
Solved
I'm trying to print a date from a string like "01/01/01" and get something like "Monday First January 2001.
I found something with the man of ctime but really don't get it how to use it.
Any help...
1
I'm compiling in VS 2010 with boost 1_53.
I'm also using boost's threads.
during compilation i'm getting bunch of errors like this
c:\program files (x86)\microsoft visual studio 10.0\vc\include...
Proselytism asked 28/5, 2014 at 8:55
4
Solved
I'm using time.h in C++ to measure the timing of a function.
clock_t t = clock();
someFunction();
printf("\nTime taken: %.4fs\n", (float)(clock() - t)/CLOCKS_PER_SEC);
however, I'm always getti...
Principle asked 15/1, 2013 at 12:2
2
Solved
I'm trying to format a 10-digit Unix time stamp (currently a string) using ctime.
However, ctime() expects a parameter of type time_t, not a string.
What must I do before I can use ctime?
In othe...
Constitutional asked 5/9, 2012 at 17:0
1
Solved
Let's clarify this once and for all. I tried to Google this but it seems this information can't be found in one place.
When a file is created or removed, the holding directory mtime changes on Win...
Janeljanela asked 17/7, 2012 at 8:12
1
Solved
How can I set a Unix file's ctime?
(I'd much prefer an answer in terms of Python. If there's no way to do it with standard Python, then I suppose C is OK too.)
(Note: I know that one can us...
6
Solved
I would like to use the tm struct as a static variable in a class. Spent a whole day reading and trying but it still can't work :( Would appreciate if someone could point out what I was doing wrong...
1 Next >
© 2022 - 2025 — McMap. All rights reserved.