By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,617 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,617 IT Pros & Developers. It's quick & easy.

Simple question

P: n/a
Hi all,

Is there a place in the .NET framework where simple time constants are
defined?

For example:
How many days are there in a week? Hours in a day? Minutes in an hour?
Seconds in a minute?

None of these are going to change, so they are obviously constants. Now I
can define my own constants, but it would be just as easy to use the
frameworks constants.....if I could find them.....

The logical place to look was System.DateTime.DaysInOneWeek; however, this
does not exist.

Thanks,
Dave
Nov 20 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
TimeSpan has the TicksPerWhatever constants, but no; you may need to add
your own constants if you value this...

Marc
Nov 20 '06 #2

P: n/a
Hi Dave,

The problem is that they may change depending on the locale of the computer running the code.
Calendars vary from culture to culture, and so I assume time constants may as well.

The type of information you have requested would normally be found in the
System.Globalization.CultureInfo.CurrentCulture object, however I couldn't find any properties or
methods that seem to apply. Take a look and maybe you'll have better luck than I have.

--
Dave Sexton

"D. Yates" <fo****@hotmail.comwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi all,

Is there a place in the .NET framework where simple time constants are defined?

For example:
How many days are there in a week? Hours in a day? Minutes in an hour? Seconds in a minute?

None of these are going to change, so they are obviously constants. Now I can define my own
constants, but it would be just as easy to use the frameworks constants.....if I could find
them.....

The logical place to look was System.DateTime.DaysInOneWeek; however, this does not exist.

Thanks,
Dave

Nov 20 '06 #3

P: n/a
I think it'd save you time to define them yourself in a central enum
....

On Mon, 20 Nov 2006 10:41:48 -0600, "D. Yates" <fo****@hotmail.com>
wrote:
>Hi all,

Is there a place in the .NET framework where simple time constants are
defined?

For example:
How many days are there in a week? Hours in a day? Minutes in an hour?
Seconds in a minute?

None of these are going to change, so they are obviously constants. Now I
can define my own constants, but it would be just as easy to use the
frameworks constants.....if I could find them.....

The logical place to look was System.DateTime.DaysInOneWeek; however, this
does not exist.

Thanks,
Dave
--

Bits.Bytes.
http://bytes.thinkersroom.com
Nov 20 '06 #4

P: n/a
You might find that you can obtain these constants via TimeSpan. E.G.

static int hoursInDay = (new TimeSpan(1,0,0,0)).Hours; or
TimeSpan.FromDays(1.0).Hours;

and similar techniques. Or, it may be you need these constants only in the
context of figuring a time span or a date, in which case it would be better
to use DateTime and/or TimeSpan directly.

"D. Yates" <fo****@hotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi all,

Is there a place in the .NET framework where simple time constants are
defined?

For example:
How many days are there in a week? Hours in a day? Minutes in an hour?
Seconds in a minute?

None of these are going to change, so they are obviously constants. Now I
can define my own constants, but it would be just as easy to use the
frameworks constants.....if I could find them.....

The logical place to look was System.DateTime.DaysInOneWeek; however, this
does not exist.

Thanks,
Dave

Nov 20 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.