-1

I am currently coding a library/framework to use in my future projects. I am trying to decide on a good name for a date time type class.

Most likely I will be extending PHP's Datetime class, but add my own methods to it. Some methods include:

  • displaying dates and times in different formats
  • getting list of time zone options
  • setting users time zone
  • getting users set timezone
  • adjusting dates and times according to users time zone
  • difference between 2 times/dates
  • other similar date and time functions

Based on that, what would you name a class that had methods to do such tasks?

Because PHP has a Datetime class already, I believe I will have to name it something different?

Ideas

  • Dateandtime.class.php
  • dates.class.php

Ideas?

Community
  • 1
  • 1
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
  • 1
    It probably also plays a role what naming scheme your other classes follow. Can you show some examples? – Pekka Jan 26 '11 at 21:04
  • 3
    `dateTimePlus` or `dateTimeExtended` would be my two first natural suggestions. – Sampson Jan 26 '11 at 21:04
  • 1
    Ok... at least two thirds of the features you enumrated are already implemented in DateTime or it's companion classes. Unless there's something special about it, which didn't make into your question, try not to reinvent the wheel. – Mchl Jan 26 '11 at 21:09
  • 3
    DateTime2AvengeTheRevenger. Or DT2ATR, 'cause that's Hollywood style. – David Jan 26 '11 at 21:10
  • Note that you're providing file names, not class names. The two are not the same thing. – user229044 Jan 26 '11 at 21:12
  • Where comes the 'location' from the question title? – xtofl Jan 26 '11 at 21:13
  • @Pekka so far the library type classes are simple... Router.class.php Cache.class.php Database.class.php Language.class.php Logger.class.php Config.class.php, etc.... – JasonDavis Jan 26 '11 at 21:15
  • @xtofl 'location' should of been 'timezones' – JasonDavis Jan 26 '11 at 21:17

5 Answers5

3

I think DateTimeHelper fits for this.

You can name the file what you like, but keep it similar to the name of your class. It's the class name that would cause problems, not the filename.

Damon Skelhorn
  • 1,491
  • 11
  • 18
3

What about these?

  • DateTime2
  • DateTimeHelper
  • DateTimeExt
  • My_DateTime (or another prefix)

Some inspired by Java classes:

  • DateUtils
  • Calendar
Koraktor
  • 41,357
  • 10
  • 69
  • 99
2

You can add your framework name as a prefix for your class names (i.e Zend_*) You can use another naming convention - add a number after the class (i.e Datetime2.php) Another idea is to add Helper/Manager as a suffix. It all depends on how you are going to se the class ;)

Radoslav Georgiev
  • 1,366
  • 8
  • 15
  • The prefix is a brilliant basic suggestion, as it also makes eady autoloading possible in a multi-library environment. `MyFramework_Date` or `MyFramework_Datetime` would then be natural choices – Pekka Jan 26 '11 at 21:17
1

You said the class has something to do with location, so my thought was "GeoDateTime"

Brian
  • 15,599
  • 4
  • 46
  • 63
0

If you're using namespaces (PHP 5.3+ only) why not:

namespace MyFramework;

class DateTime extends \DateTime 
{
    \\ ...
}

and then use it;

use MyFramework\DateTime;

$myDateTime = new DateTime();
noisebleed
  • 1,299
  • 2
  • 12
  • 26