The MASM Forum

Specialised Projects => Compiler Based Assembler => Topic started by: herge on January 19, 2013, 10:04:46 AM

Title: A time & Date in VC2008
Post by: herge on January 19, 2013, 10:04:46 AM

 Hi C++  fans!

Code: [Select]
// GMT.cpp : Defines the entry point for the console application.
// Friday, January 18, 2013 3:55 PM
#include "stdafx.h"
// crt_gmtime.c
// compile with: /W3
// This program uses _gmtime64 to convert a long-
// integer representation of coordinated universal time
// to a structure named newtime, then uses asctime to
// convert this structure to an output string.
#include <time.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
using std::cout;
using std::endl;
int _tmain(int argc, _TCHAR* argv[])
{
   struct tm *newtime;
   struct tm today;
   __int64 ltime;
   char buff[128];
   errno_t err;
   _time64( &ltime );
   // Obtain coordinated universal time:
   newtime = _gmtime64( &ltime ); // C4996
   // Note: _gmtime64 is deprecated; consider using _gmtime64_s
   asctime_s( buff, sizeof(buff), newtime );
   int i;
   for ( i = 0; i < sizeof(buff); i++  )
   { // Remove line Feed with Space
   if( buff [ i ] == 10 ) buff [ i ] = 32;
   }
   cout << "Coordinated universal time is "
    << buff << "UTC"
        << endl;
   // Use time structure to build a customized time string.
    err = _localtime64_s( &today, &ltime );
    if (err)
    {
        cout << " _localtime64_s failed due to Bad arguments.";
        exit(1);
    }
   strftime( buff, 128,
         "Today is %A, day %d of %B in the year %Y.\n", &today );
   cout << buff;
   strftime( buff, sizeof(buff),"%#c %p %z", &today );
   cout << buff << endl;
   _getch(); // Wait!
   return 0;
}
/* expected output
Coordinated universal time is Fri Jan 18 22:00:58 2013 UTC
Today is Friday, day 18 of January in the year 2013.
Friday, January 18, 2013 17:00:58 PM EST
*/



I have Windows XP SP3

Regards Herge
Title: Re: A time & Date in VC2008
Post by: Vortex on January 19, 2013, 07:46:53 PM
Hi herge,

Hi C fans!

You posted C++ code.
Title: Re: A time & Date in VC2008
Post by: herge on January 19, 2013, 08:01:08 PM

 Hi Vortex:

 Yes it is C++ but C is quicker to type.

 I prefer an old Borland compiler.

 Regards Herge
Title: Re: A time & Date in VC2008
Post by: Gunther on January 19, 2013, 11:51:22 PM
Hi herge,

and what is your question?

Gunther
Title: Re: A time & Date in VC2008
Post by: herge on January 20, 2013, 12:25:18 AM

Hi Gunther:

 What's up?

 Regards herge
Title: Re: A time & Date in VC2008
Post by: herge on January 20, 2013, 01:15:31 AM
 I have discovered if you go Microsoft with AOL 9
 you get a lot of internet script errors. But if I use IE it works
 well even with the reduced band width because
 Aol has the connection.

 Regards Herge
Title: Re: A time & Date in VC2008
Post by: herge on January 21, 2013, 01:28:29 AM
Hi Everbody:

To get rid of specific warning in 2008 vc++ or 2005 vc++
Code: [Select]
1>c:\documents and settings\user\my documents\visual studio 2008\projects\gmt\gmt\gmt.cpp(25) : warning C4996: '_gmtime64': This function or variable may be unsafe. Consider using _gmtime64_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1>        c:\program files\microsoft visual studio 9.0\vc\include\time.h(209) : see declaration of '_gmtime64'
Project Properties
 Configuration Properties
 C/C++
 Advanced
 Disable Specific Warnings
 4996
 OK

 You will find the
#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_SECURE_NO_DEPRECATE 1
#pragma warning( disable : 4996 )


 Will not work!

 Regards herge


 
Title: Re: A time & Date in VC2008
Post by: K_F on March 10, 2013, 02:24:03 AM
Deleted..
Hutch - I was replying to another post and it posted here !

This is with reference to the logging in - and posting problem I mentioned earlier :0