473,786 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Parse date and time in unmanaged C++

Hi all,

I need to simulate current date and time and provide integer values for the
current year, month, day, hour, minute, second, and millisec. I need to do
this in unmanaged C++. My first inclination is to do roughly the same thing
that I would do in managed code: I would maintain a 64-bit integer value
that represents the number of millisec. (or nanosec.) since some date. I
would periodically increment this integer by the appropriate amount. My
question is, is there an unmanaged C/C++ function (maybe something buried in
the Windows API) that can perform the year/month/date conversion for me?
TIA!
Jun 28 '06 #1
2 2818
My personal favourite time-date routines is CComDate found at
http://www.sellsbrothers.com/tools/

Brian
Jun 28 '06 #2
"Bob Altman" wrote:
Hi all,

I need to simulate current date and time and provide integer values for the
current year, month, day, hour, minute, second, and millisec. I need to do
this in unmanaged C++. My first inclination is to do roughly the same thing
that I would do in managed code: I would maintain a 64-bit integer value
that represents the number of millisec. (or nanosec.) since some date. I
would periodically increment this integer by the appropriate amount. My
question is, is there an unmanaged C/C++ function (maybe something buried in
the Windows API) that can perform the year/month/date conversion for me?
TIA!


See the Win32 FILETIME and SYSTEMTIME structures and associated functions
like FileTimeToSyste mTime. They do almost exactly what you describe above,
and can do additional things like time zone conversion, locale-specific
calendars, and more. I use them for all sorts of unmanaged date/time tasks.

Sean
Jun 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
9448
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $ Last-Modified: $Date: 2003/10/28 19:48:44 $ Author: A.M. Kuchling <amk@amk.ca> Status: Draft Type: Standards Track
2
5073
by: Peter Kleiweg | last post by:
Is there a safe and clean way to parse a date/time string into seconds since epoch? I have a string with date and time in GMT. I can get the correct value using this: #!/usr/bin/env python import os os.environ = 'UTC'
2
4185
by: Joshua Moore | last post by:
Does anyone know how I'd set the local computer's date/time in C#? Thanks in advance, Joshua Moore
9
1976
by: Shapper | last post by:
Hello, I created a dataset from a XML file. One of the dataset fields is . In an ASP:Repeater I am displaying the field. <%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %> The date displayed has the following format, the same as in the XML file:
5
5903
by: Johnaton | last post by:
hi, I have this problem with the date time picker, when I bind the control to data table and add new record, it is ok, however, if I delete all records via a button using the me.bindingcontext(datatable).removeat(me.bindingcontext(dataTable).position) statement, it always throw the following error .. A first chance exception of type 'System.ArgumentException' occurred in system.dll
10
8462
by: okaminer | last post by:
Hi I have a program which need to get the date in the format of dd/MM/yyyy (example 24/7/2005) but when I use DateTime.Now().ToShortDatetime() the date come back as MM/dd/yyyy (example 7/24/2005) This cause much problems I would like to know how to change the .NET regional setting so the
6
4320
by: Tim N. van der Leeuw | last post by:
Hi, I want to parse strings containing date-time, which look like the following: "Mon Dec 19 11:06:12:333 CET 2005" That's a problem for strptime it seems, b/c I cannot find any format-spec for the milliseconds-part in here. (I'm also not sure about the validity of the tz part, but ...)
7
4242
by: Jerome | last post by:
Hallo, I know a lot has already been told about date/time fields in a database but still confuses me, specif when dealing with SQLserver(Express). It seems that sqlserver only accepts the date in a "yyyyMMdd" format? (difference between Express and MSDE2000A ?) What is the one and only true way to deal with this problem in VB2005: Local settings are Dutch (Belgium) ; thus date is in "dd/MM/yy" (or perhaps dd/MM/yyyy) and time in...
21
16604
by: rdemyan via AccessMonster.com | last post by:
Is there a way to get the internet date/time. I saw an article that uses WinSock, but WinSock doesn't seem to be available in Access. I want to verify that the date/time on the local PC running my application is correct, so I was hoping I could get the Internet date/time. I understand that there is a NTP protocol to do this. Thanks. --
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.