G
Gavin Kistner
I've just finished my first general-purpose Ruby class, MutableTime.
You can read the RDocs for it at http://phrogz.net/RubyLibs/ (and you
can download it from the link at the bottom of the page for the
MutableTime.rb file)
What is MutableTime? It arose out of my desire for a Date/Time class in
Ruby that behaves like the Date object in JS. From the MutableTime docs:
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
The MutableTime class behaves much like the builtin Time class, except:
* almost any property can be changed, e.g.
mmTime = MutableTime.new
mmTime.year = 1973
mmTime.month += 13
* by default, month numbers start at 0 instead of 1
— see monthsStartAtZero?
* you can choose if the first day of the week is Sunday or Monday
— see weekStartsOnMonday?
* it has convenience methods named similar to JavaScript’s Date object
— fullYear, month, date, hours, minutes, seconds
* customFormat is slightly more powerful than Time#strftime
* you can easily internationalize the month and day names
(without editing the source code for the class)
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
Please try it out and tell me what you think.
Also...what's the standard protocol for releasing new classes like this?
Is there somewhere that I should upload the .rb file to? Somewhere other
than here that I should announce it?
You can read the RDocs for it at http://phrogz.net/RubyLibs/ (and you
can download it from the link at the bottom of the page for the
MutableTime.rb file)
What is MutableTime? It arose out of my desire for a Date/Time class in
Ruby that behaves like the Date object in JS. From the MutableTime docs:
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
The MutableTime class behaves much like the builtin Time class, except:
* almost any property can be changed, e.g.
mmTime = MutableTime.new
mmTime.year = 1973
mmTime.month += 13
* by default, month numbers start at 0 instead of 1
— see monthsStartAtZero?
* you can choose if the first day of the week is Sunday or Monday
— see weekStartsOnMonday?
* it has convenience methods named similar to JavaScript’s Date object
— fullYear, month, date, hours, minutes, seconds
* customFormat is slightly more powerful than Time#strftime
* you can easily internationalize the month and day names
(without editing the source code for the class)
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
Please try it out and tell me what you think.
Also...what's the standard protocol for releasing new classes like this?
Is there somewhere that I should upload the .rb file to? Somewhere other
than here that I should announce it?