Questions tagged [ctime]

CTime Class The upper date limit is 12/31/3000. The lower limit is 1/1/1970 12:00:00 AM GMT.

CTime does not have a base class.

CTime values are based on coordinated universal time (UTC), which is equivalent to Greenwich mean time (GMT). The local time zone is controlled by the TZ environment variable.

When creating a CTime object, set the nDST parameter to 0 to indicate that standard time is in effect, or to a value greater than 0 to indicate that daylight savings time is in effect, or to a value less than zero to have the C run-time library code compute whether standard time or daylight savings time is in effect. tm_isdst is a required field. If not set, its value is undefined and the return value from mktime is unpredictable. If timeptr points to a tm structure returned by a previous call to asctime, gmtime, or localtime, the tm_isdst field contains the correct value.

A companion class, CTimeSpan, represents a time interval.

The CTime and CTimeSpan classes are not designed for derivation. Because there are no virtual functions, the size of CTime and CTimeSpan objects is exactly 8 bytes. Most member functions are inline.

252 questions
0
votes
1 answer

Can't time input: C++

I am trying to make a game to test my C++ skills, and in the game I created a class called Player with the method function definition attack(). It prints a random string based on a Player method variable, and then it asks the player to input that…
Chopdops
  • 11
  • 1
  • 8
0
votes
0 answers

Detect windows time change c++

I am using CTime t = CTime::GetCurrentTime(); to get the current time from Winodws, but when the clock changes the next day and the application is still open, the time does not change. How can i make 't' be updated automatically when time…
Mike
  • 35
  • 1
  • 7
0
votes
1 answer

How do I convert a time to tm struct instead of CTime class

I currently have code that creates a CTime object from a defined value. #define TIME_VALUE 0x301DDF00 // Aug 1, 1995 @ 04:00:00 CTime t = CTime( TIME_VALUE ); This creates the desired date of Aug 1, 1995 04:00:00 I can no longer use CTime so I am…
0
votes
1 answer

How to use ctime to mark starting and ending point of the program?

time_t start; time_t no_infection; bool time_already_set = 0; bool infected_or_not = 0; int not_infected_t = 0; I have this variables in struct and I want to mark starting and ending point of the objects, than calculate the difference. void…
0
votes
2 answers

Convert a local time with timezone into UTC with ctime

I have been wracking my head crazy trying to figure this out with this API My original implementation was something like: // TimezonePtr is just a share_ptr to the timezone std::tm getGMT(const std::tm& rawtime, TimezonePtr tz) { std::tm result…
Addy
  • 2,414
  • 1
  • 23
  • 43
0
votes
2 answers

PHP - How to set ctime of a file in Unix system

Is it possible to set ctime of a file to a desired value. I am working on a restore script and I need to set the ctime of the file to a previous timestamp after restoring the file. I tried touch function, but it only sets the atime and mtime.
Yasitha
  • 2,233
  • 4
  • 24
  • 36
0
votes
0 answers

CTIME useage in an array

I am trying to use time.h to convert a POSIX time into a time structure, thus making the string human readable. The string is located in a .bin file I have. I understand how to use it outside of a function, such as time_t rawtime; time…
Patrick Daniels
  • 51
  • 1
  • 1
  • 7
0
votes
1 answer

Want to show create time for some files.

I was writing perl and run it in window system pretty good . But when i transfer the perl script from windows system to Linux. And run in Linux system , i get wrong date/time. Need some help. Thanks. The source code in Perl if (($file =~…
cs87
  • 37
  • 7
0
votes
1 answer

Incorrect time calculation with mktime to get UTC+8

I want to get the current time in Hong Kong (UTC+8), and my local time is UTC-5. Using and running the following in VS2012: #pragma warning(disable : 4996) char buffer[10]; time_t rawtime; time(&rawtime); strftime(buffer, 10, "%H:%M:%S",…
feetwet
  • 3,248
  • 7
  • 46
  • 84
0
votes
1 answer

How to use randomly generated number in switch statement?

i am making a simple program that displays the behaviour of the person from the sentences that i write in switch statement cases. I want to randomly generate a number between 1 and 10 and use it in "switch(this place)". So far, i have written the…
0
votes
2 answers

how to display datetime using C Programming

I have to display date and time separately using gettime() and getdate() in C programming language. The code I have written only displays date and time on same line. I want this code to be done using only core C not in a windows format.The editor I…
0
votes
1 answer

Local Time reverts to UTC in nohup file

I have some programs that write to nohup files with date stamps. When the programs are run in a terminal and printed to the screen, the date shows the correct local time. However, when the programs are started from bootup with a nohup command and…
DaDaDadeo
  • 53
  • 6
0
votes
2 answers

Comparing File Dates in a Directory

I am trying to write a script in Python to upload a series of photos depending on the dates they were created. I am having an issue of comparing the dates of each of the files to a date before and after the dates I want so that I can create an array…
Illyduss
  • 161
  • 1
  • 3
  • 11
0
votes
1 answer

How do you obtain a formatted date and time for the current locale in C?

What C function should I call to obtain a formatted date and time for the locale where the program is being executed? I'm asking this question because I have run into a problem using the ClamAV daemon API. The VERSION command returns the date and…
jwaddell
  • 1,892
  • 1
  • 23
  • 32
0
votes
3 answers

math with ctime and time_t

Does anyone know how todo math with ctime? I need to be able to get the time in sec in "time_t" (like it normally does) and then subtract a set number of seconds from it before inputting time_t into ctime to get the time and date. so basically it…
Lightning77
  • 313
  • 5
  • 14