This is not strictly a C++ issue but if anyone will know the answer its you
guys!
I am trying to figure out a date format stored in the registry by a piece of
software (I am trying to write something to enable me to script a
configuration). The program stores a createdate for a set of registry keys
held in a DWORD value. I assumed it would be the number of seconds since
epoch (1/1/1970 00:00:00) - but its not. Here is a couple of examples:
19/12/2002 11:41:38 = 764632371
13/12/2002 11:36:58 = 764239005
Any one have any other ideas????
Thanks
Lee 6 22292
"Lee K" <no***@nothere. com> wrote... This is not strictly a C++ issue but if anyone will know the answer its
you guys!
I am trying to figure out a date format stored in the registry by a piece
of software (I am trying to write something to enable me to script a configuration). The program stores a createdate for a set of registry
keys held in a DWORD value. I assumed it would be the number of seconds since epoch (1/1/1970 00:00:00) - but its not. Here is a couple of examples:
19/12/2002 11:41:38 = 764632371 13/12/2002 11:36:58 = 764239005
Any one have any other ideas????
Looks like your DWORD is a (<date> << 16) + <time>. Perhaps even
the regular packed MSDOS date and time values. Remember those?
bits:
Date: YYYYYYYMMMMDDDD D
Time: HHHHHMMMMMMSSSS S, where S is half of real seconds.
So, to calculate the date you need to do
void breakDate(DWORD dvalue, int& year, int& month, int& day,
int& hour, int& minute, int& sec)
{
year = (dvalue >> 25) + 1980;
month = (dvalue >> 21) & 0xf;
day = (dvalue >> 16) & 0x1f;
hour = (dvalue >> 11) & 0x1f;
minute = (dvalue >> 5) & 0x3f;
sec = (dvalue & 0x1f) * 2;
}
It's possible to have invalid values. Month can be more than 12,
day can be more than the nubmer of days in the month, hours could
be > 23, minutes can be > 59, seconds could be > 59.
Victor
You are right - thank you very much.
What is the best way to actually create the DWORD value from the current
date?
Thanks,
Lee
"Victor Bazarov" <v.********@att Abi.com> wrote in message
news:vh******** ****@corp.super news.com... "Lee K" <no***@nothere. com> wrote... This is not strictly a C++ issue but if anyone will know the answer its you guys!
I am trying to figure out a date format stored in the registry by a
piece of software (I am trying to write something to enable me to script a configuration). The program stores a createdate for a set of registry keys held in a DWORD value. I assumed it would be the number of seconds
since epoch (1/1/1970 00:00:00) - but its not. Here is a couple of examples:
19/12/2002 11:41:38 = 764632371 13/12/2002 11:36:58 = 764239005
Any one have any other ideas????
Looks like your DWORD is a (<date> << 16) + <time>. Perhaps even the regular packed MSDOS date and time values. Remember those?
bits:
Date: YYYYYYYMMMMDDDD D Time: HHHHHMMMMMMSSSS S, where S is half of real seconds.
So, to calculate the date you need to do
void breakDate(DWORD dvalue, int& year, int& month, int& day, int& hour, int& minute, int& sec) { year = (dvalue >> 25) + 1980; month = (dvalue >> 21) & 0xf; day = (dvalue >> 16) & 0x1f; hour = (dvalue >> 11) & 0x1f; minute = (dvalue >> 5) & 0x3f; sec = (dvalue & 0x1f) * 2; }
It's possible to have invalid values. Month can be more than 12, day can be more than the nubmer of days in the month, hours could be > 23, minutes can be > 59, seconds could be > 59.
Victor
"Lee K" <no***@nothere. com> wrote... You are right - thank you very much.
What is the best way to actually create the DWORD value from the current date?
Use << and | operators and just do the reverse of what
I did in the breakDate.
Victor
"Lee K" <no***@nothere. com> wrote... Victor,
I tried that but am obviously making a school boy error as it does not
work, any chance you could post an example???
If we want to make 'XXXKKKKKPPPP' out of three values x, k, and p,
then one approach could be
result = ((x & 7) << 9) | ((k & 31) << 4) | (p & 15);
Can you figure out why '7', '9', '31', '4', and '15'? Let it be
your homework.
Victor
Got the answer in the end thanks to Victor!
int yr = 0;
int month = 0;
int day = 0;
int hour = 0;
int minute = 0;
int sec = 0;
CTime n = CTime::GetCurre ntTime();
DWORD dValue = 0;
yr = n.GetYear();
month = n.GetMonth();
day = n.GetDay();
....
dValue = ((yr - 1980) << 25) | ((month & 0xF) << 21) | ((day & 0x1F) << 16)
| ((hour & 0x1F) << 11) | ((minute & 0x3F) << 5) | (sec / 2);
Thank you for your help.... This is why ng's are so great
Lee
"Lee K" <no***@nothere. com> wrote in message
news:3f******** *************** @mercury.nildra m.net... This is not strictly a C++ issue but if anyone will know the answer its
you guys!
I am trying to figure out a date format stored in the registry by a piece
of software (I am trying to write something to enable me to script a configuration). The program stores a createdate for a set of registry
keys held in a DWORD value. I assumed it would be the number of seconds since epoch (1/1/1970 00:00:00) - but its not. Here is a couple of examples:
19/12/2002 11:41:38 = 764632371 13/12/2002 11:36:58 = 764239005
Any one have any other ideas????
Thanks
Lee
"Lee K" <no***@nothere. com> wrote... int yr = 0; int month = 0; int day = 0; int hour = 0; int minute = 0; int sec = 0; CTime n = CTime::GetCurre ntTime(); DWORD dValue = 0;
yr = n.GetYear(); month = n.GetMonth(); day = n.GetDay(); ...
dValue = ((yr - 1980) << 25) | ((month & 0xF) << 21) | ((day & 0x1F) <<
16) | ((hour & 0x1F) << 11) | ((minute & 0x3F) << 5) | (sec / 2);
Add some protection to this. Verify that the year you get is,
in fact >= 1980. Otherwise subtracting 1980 from it may lead
to unexpected or even undefined results.
Good luck with your project!
Victor This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: darrel |
last post by:
I have the following right now to enter a date into SQL getting the data
from some pull down menus:
-------------------------------------------------
dim dateCCJApprovedDate as DateTime
if cbx_ccjDateNone.Checked = True then
dateCCJApprovedDate = ctype("", DateTime)
else
dateCCJApprovedDate = ctype(ddl_CCJDateMonth.SelectedValue.tostring &
|
by: abcabcabc |
last post by:
I write an application which can let user define own date format to input,
How to convert the date string to date value with end-user defined date
format?
Example, User Defined Date Format as "dd/MM/yyyy"
input as "01082003" convert to date value as, 01 Aug 2003
Example, User Defined Date Format as "yyyy,dd,MM"
|
by: Cyberdyne |
last post by:
Here is the problem,
I have a form with a field named Occurence with a Short Date Value, once entered it subsequently appears in 3 fields SOL1 which adds one year, SOL2 which adds 2 years and SOL6M which adds 6 month to the date entered in the Occurence field, this is done with the following Controls:
=DateAdd("yyyy",1,)
=DateAdd("yyyy",2,)
=DateAdd("m",6,)
The problem is that the data in the SOL1, SOL2, and SOL6M does not show up...
|
by: Aussie Rules |
last post by:
Hi,
I have a datepicker that show a calender. The user picks a date and the
time component is always 00:00.
I then have a drop down that provides a list of times, (10:00, 11:00 etc),
and I want to combine this with the date value, so that I can store it in a
single field in the database.
How can I combine these two values into one ?
|
by: MackTheKnife |
last post by:
Hi,
I'm trying to write a java.sql.Date to a database and the minutes/
seconds etc. are not being written. I've seen and tested many
examples
found via searches and still have come up with nothing. Here's what I
have:
java.sql.Date formation - recommended constructor forms:
java.sql.Date entryDttm = new
java.sql.Date(System.currentTimeMillis());
| |
by: salo |
last post by:
Hi ........Im working with c# and asp.net and i have two calendar control in my form and i want the cliked date value to be get displayed in the textbox.
i gave the code as
TextBox1.Text = Calendar1.SelectedDates.ToString();
in page load event but while running nothing is displayed.
and also after getting the date in the textbox ...i have to subtract the from date and to date
plz can anybody help me....
|
by: Bharathi |
last post by:
Hi,
I got strucked with reading date value from excel file using
C#.NET.
For Jan-2000 the value I am getting is 36526.0.
For all other dates also I am getting some double value like this.
Is there any manipulation so that I can find out the date entered in
|
by: Rob Wilkerson |
last post by:
Surprisingly (at least to me), there doesn't seem to be a built-in
function to validate a date value (like, say, is_date()). Given that,
is there a best practice for determining whether a value is a valid
date/time? The values I need to test will likely be unix timestamp
values and I need to be able to distinguish them as date/time values
from other integer/numeric values.
What I'm trying to do is use reflection to iterate over the...
|
by: vikas251074 |
last post by:
I am not getting date value in spite of my good effort. This code was working in my last office where I work. Now I am trying to work at my home pc. but not getting date value. Any can help me why this happens. This is my part of code given below.
<%@ Language=VBScript%>
<%Option Explicit%>
<html>
<head>
<title>SABF</title>
<!--#include file="font.css"-->
|
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,...
|
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...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |