DateTime, but why no Date class?

M

Mantorok

Hi all

I've never really been a fan of always having to use a DateTime type when
9/10 times I only want to store a Date.

The main problem I've got now is that I have some user controls and I want
to determine whether the DateTime value I have should be displaying the
date-only or both date and time.

I take it there is no way on this earth that it can be determined what the
intentions are of a DateTime instance?

Thanks
Kev
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Correct.

As the DateTime value always has a time, there is no telling if it was
created with the specific time 00:00 or without a time so that the
default time 00:00 was used.
 
M

Mantorok

Mark Rae said:
http://www.msnewsgroups.net/group/microsoft.public.dotnet.languages.csharp/topic6617.aspx

One of the great things about the Framework is that, if you don't like
something straight out of the box, just modify it till it fits, or extend
it, or create something else entirely and use that...

Yeah I'll have to do that if there is no way it can be done with the
existing class, this is what gets me about the Framework, on one side you
have strokes of genius, on the other you may have the most simplest problem
overlooked.

Unless of course there was a very good reason "not" to have a System.Date
class.

Kev
 
M

Mark Rae

Yeah I'll have to do that if there is no way it can be done with the
existing class, this is what gets me about the Framework, on one side you
have strokes of genius, on the other you may have the most simplest
problem overlooked.

I guess it's a trade-off between feature richness and feature bloat...

Somebody asked recently why there's no built-in method to convert Imperial
to Metric, Fahrenheit to Celsius etc...
Unless of course there was a very good reason "not" to have a System.Date
class.

That I can't answer
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,
Yeah I'll have to do that if there is no way it can be done with the
existing class, this is what gets me about the Framework, on one side you
have strokes of genius, on the other you may have the most simplest
problem overlooked.

It's impossible to accomodate ALL the possible requirements of all the
programmers. The important thing is that you can extend AND modify the
classes at your convenience.
Unless of course there was a very good reason "not" to have a System.Date
class.

Maybe cause it's not that important? I've been programming several years now
in .net and I have never ever needed such a distinction.
 
M

Mantorok

Ignacio Machin ( .NET/ C# MVP ) said:
Hi,


It's impossible to accomodate ALL the possible requirements of all the
programmers. The important thing is that you can extend AND modify the
classes at your convenience.

I can modify the framework classes? How? Or did you mean modify the
descendant classes?
Maybe cause it's not that important? I've been programming several years
now in .net and I have never ever needed such a distinction.

What do you display in your UI if you query a DateTime value? Do you convert
it to a short format if you need to or do you leave it displaying the
trailing zeros?

Kev
 
M

Mark Rae

I can modify the framework classes? How?

Inasmuch as you can derive new classes from them and override the
functionality...
Do you convert it to a short format if you need to

Yes - this is just presentation... Same was as I choose how many decimal
places to display in numeric values, etc...
 
M

Mantorok

Mark Rae said:
Inasmuch as you can derive new classes from them and override the
functionality...

Except for sealed classes of course, which is what DateTime is, suppose I'll
have to create a wrapper for it.
Yes - this is just presentation... Same was as I choose how many decimal
places to display in numeric values, etc...

Yeah I suppose it's the same when you thnk about it.

Kev
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Mark said:
I guess it's a trade-off between feature richness and feature bloat...

Somebody asked recently why there's no built-in method to convert Imperial
to Metric, Fahrenheit to Celsius etc...

Let me guess...

Someone doing a beginners course in programming, and trying to avoid
learning anything?

;)
 
G

Guest

Mantorok,
I understand your frustration. Mark's link to the other solution I thought
was excellent. I've worked with .NET for 5+ years now, and have never felt
the need to have a "Date" class, since you can always wrap it or simply get
out what you need and not have to worry about the time component.


Cheers,
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top