Date:: ... MakeHash? :-|

cog on 2004-11-09T10:43:06

Date::MakeHash, a prototype (OK, OK, I couldn't sleep).

What I'd like to know is:

1) Is it any good?

2) Does something like that already exist on the CPAN? (because if it does, I'm having trouble finding it)

3) If it is any good and nothing like it exists (yeah, sure, get real), any general comments on it?

TIA :-)


Re: Date:: ... MakeHash? :-|

davorg on 2004-11-09T11:06:43

A few comments from a brief look at the code.

* I think you have trimester and quartermaster the wrong way round.

* Does 'quartermaster' have the meaning you're trying to give it here? Maybe it should be 'quartermester'.

* Your calculation of whether a year is a leap year is incorrect (1900 and 2100 are not leap years).

* Would it make sense to also have a "make_gm_hash" function?

* Looks like most (all?) of your reference data hashes would be better implemented as arrays.

* With a module that only exists in order to export a single subsroutine, it probably makes sense to put that subroutine in @EXPORT instead of @EXPORT_OK.

Hope this helps.

Re: Date:: ... MakeHash? :-|

cog on 2004-11-09T11:16:43

* I think you have trimester and quartermaster the wrong way round.

Probably... I said I couldn't sleep, I didn't say I wasn't sleepy O:-)

* Does 'quartermaster' have the meaning you're trying to give it here? Maybe it should be 'quartermester'.

Probably so (I had a note here to check the meaning of the word in a dictionary)

* Your calculation of whether a year is a leap year is incorrect (1900 and 2100 are not leap years).

I am aware of that, but thanks for noting :-)

* Would it make sense to also have a "make_gm_hash" function?

I don't get this one... what would that do? :-|

* Looks like most (all?) of your reference data hashes would be better implemented as arrays.

OK. Will do.

* With a module that only exists in order to export a single subsroutine, it probably makes sense to put that subroutine in @EXPORT instead of @EXPORT_OK.

Sounds fair

Hope this helps.

It does. Thanks for your input :-)

Re: Date:: ... MakeHash? :-|

davorg on 2004-11-09T12:20:53

* Would it make sense to also have a "make_gm_hash" function?
I don't get this one... what would that do? :-|

It would do exactly the same thing as "make_hash", except it would use "gmtime" instead of "localtime".

A couple more suggestions:

* Call the function "make_date_hash" instead of "make_hash".

* If no argument is given, call "localtime" without an argument - to get a hash representing the current date and time.

Time::localtime

link on 2004-11-09T20:13:03

Looks quite like Time::localtime to me.

Maybe you should return an object instead of hash, that way if you decide to add something that requires non trivial calculation only those people interested in it pay the cost.

Re:Time::localtime

cog on 2004-11-09T20:52:52

Yes, it is quite similar; but the idea of Date::MakeHash (or whatever name it would get) would be to provide a wider set of... thingies (infos) on a date (things as the week of the year, etc.)

The Date namespace is pretty clobbered up, in my opinion, and that's why I'm discussing this on my journal before uploading something like this.

The idea of the object seems good :-)

Time::Piece

Matts on 2004-11-09T21:23:32

Stands a very good chance of becoming like Time::Piece. Maybe that's what you're after.

Re:Time::Piece

cog on 2004-11-10T10:58:11

So it seems. But it wasn't easy to find, though.