473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Implement Absolute Time Functions?


I have a List of DateTimes that look like this

{1753-01-01 16:00:00}
{1753-01-01 22:00:00}

And I would like to do something in my WinForm/CommandLine app that
does MyMethod() every day at 16:00 and 22:00, basically ignoring the
date and just doing something based on the time. What is the best way
to implement that?

Thanks.

Jun 28 '07 #1
2 2673
On Thu, 28 Jun 2007 12:55:44 -0700, lucius <lu****@newsgroup.nospamwrote:
I have a List of DateTimes that look like this

{1753-01-01 16:00:00}
{1753-01-01 22:00:00}

And I would like to do something in my WinForm/CommandLine app that
does MyMethod() every day at 16:00 and 22:00, basically ignoring the
date and just doing something based on the time. What is the best way
to implement that?
Hmmm...this looks related to your post that I just replied to in the
..framework newsgroup. :)

If you don't care about the date, don't store the date. Don't use a data
structure that is intended to represent absolute points in time. Of
course, it goes without saying that based on this new information, my
other reply may not be relevant, since I had assumed that since you were
storing a date, you actually cared about the date.

I would use the TimeSpan struct instead, interpreting it as an offset from
midnight. So, a value of 0 would be midnight, a value of 12 hours would
be noon, etc. You would never have a TimeSpan greater than or equal to 24
hours, but that's fine. That's no different than using an int to store a
value that is never larger than (for example) 1000.

Pete
Jun 28 '07 #2
lucius <lu****@newsgroup.nospamwrote:
>
I have a List of DateTimes that look like this

{1753-01-01 16:00:00}
{1753-01-01 22:00:00}

And I would like to do something in my WinForm/CommandLine app that
does MyMethod() every day at 16:00 and 22:00, basically ignoring the
date and just doing something based on the time. What is the best way
to implement that?
Does DateTime.TimeOfDay help you?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 28 '07 #3

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

Similar topics

15
by: Prabu | last post by:
Hi, I'm new to python, so excuse me if i'm asking something dumb. Does python provide a mechanism to implement virtual functions? Can you please give a code snippet also...:) Thanx in advance...
26
by: Oplec | last post by:
Hi, I am learning standard C++ as a hobby. The C++ Programming Language : Special Edition has been the principal source for my information. I read the entirety of the book and concluded that I...
2
by: Csaba2000 | last post by:
Demo page at http://csaba.org/Demos/getRect.htm One question I've seen come up multiple times is: How can I find the abolute position of my favorite element on the page? The standard answer is...
6
by: dyw55a | last post by:
How to implement mm/dd/yyyy format for textbox? I have text box with format mm/dd/yyyy. Now I want the cursor i generated whenever user highlight this textbox and whatever user inpu replace one...
2
by: Hao Xu | last post by:
Hi everyone! I think that everyone knows ctime() in glibc: The ctime(), gmtime() and localtime() functions all take an argument of data type time_t which represents calendar time. When ...
6
by: TulasiKumar | last post by:
hi all, i have one requirement in my project.The requirement is i want to fix some domain sites in TcpIp like proxy servers behaviour.When ever end user passing the inforamtion of that domain...
6
by: Jon Slaughter | last post by:
do I have to prefix every absolute path with document root to get it to work? For some reason I thought that prefixing a path with '/' or './' with make it absolute w.r.t to document root but I...
13
by: lawpoop | last post by:
Hello all - I have a two part question. First of all, I have a website under /home/user/www/. The index.php and all the other website pages are under /home/user/www/. For functions that are...
20
by: mike3 | last post by:
Hi. (Xposted to both comp.lang.c++ and comp.programming since I've got questions related to both C++ language and general programming) I've got the following C++ code. The first routine runs in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
tracyyun
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...
0
isladogs
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...

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.