http://drupal.org/sandbox/wesnick/1168872

DESCRIPTION
--------------

Timefield is a Field API field that stores a time value, with an optional to time.
The values are stored in the database as integer offsets from 12AM. If the second value
continues into the next day, i.e. 8PM - 2AM, the second value is stored as an offset +1 day.

The real goal of this field is to provide a taxonomy capable of encapsulating date-agnostic
time values, like "Morning", "Mid-morning" with autotagging capabilities. This is achieved
through the timefield_taxonomy module.

USAGE
-------
Timefield module provides a field type 'timefield' with a default JQuery widget.
The timefield can have an optional 'to time' and various input formats, depending on your
preference. While this field is multi-value capable, I am not really sure about a use-case
for this. There are a two display formatters, time and duration. You can configure various output
formats in the format settings dialog option on the "Manage Display" section of the Field API UI.

Comments

wesnick’s picture

sorry, bad link to my sandbox

http://drupal.org/sandbox/wesnick/1168872

joachim’s picture

Status: Needs review » Needs work

Can you explain what this does that can't be done with date module, and why a new module is necessary rather than making changes to date?

wesnick’s picture

Yes, Date field is capable of storing Time data, and I tried to clarify the difference on my project page; this is the excerpt from the actual project page of my sandbox project:

Timefield is a Field API field for storing simple non-timezone time values, with an optional to time, utilizing a simple JQuery timepicker widget for input. Normally, you will want to use a Date field for all date/time values; however, this field is for use when you don't want to implement a Date field, i.e., when Year, Month, Day granularity is irrelevant.

Additionally, there is another included module, timefield_taxonomy, whose purpose is to autotag Date fields (datestamp, datetime) or Timefield fields with Taxonomy terms, using a term_reference field, with specified Timefield values. For example, You can have a Vocabulary of "Time Window" with Terms such as "Morning", "Afternoon", and "Evening" with corresponding timefields. If you create an entity with a date field, timefield_taxonomy will autotag this entity with corresponding "Time Window" terms depending on the values you input for the date field.

So, to answer you question, yes, the entirety of the core timefield module's functionality is available via date api and its fields. For some of the edge cases that I needed date field for, for values that don't need year/month/day granularity, date field is more complex than what I wanted.

wesnick’s picture

Status: Needs work » Needs review

forgot to mark as 'needs review'

svendecabooter’s picture

Priority: Normal » Critical

Marking as critical as per http://drupal.org/node/894256
Sorry for the long wait.

wesnick’s picture

Thanks for marking this critical. At this point, I have been using Rules a little more and am thinking a rules workflow might be more suitable for the auto-tagging feature of this module. However, there is still no field (as far as I can find) that encapsulates the time datatype that most databases support. It still seems to me to use a Date datatype to mimic a Time datatype as a little hackish.

At any rate, any feedback welcome, and I have no problem refactoring or scuttling altogether in favor of more a Drupalish solution.

wesnick’s picture

Priority: Critical » Normal
Status: Needs review » Closed (won't fix)

Yeah, okay, I think this functionality can be implemented better with Date/Rules. Scuttling.

wesnick’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new25.01 KB

I have found that I have continued to use this module on my own projects since my clients find Date Repeat input widget baffling. Also, people have been using this module in my sandbox. I have added some features and improved the code. I feel this module is suitable for development use and would like to see it promoted to a full project.

Attached latest screenshot of the various field outputs.

patrickd’s picture

Status: Needs review » Needs work

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
Review of the master branch:

  • Lines in README.txt should not exceed 80 characters, see the guidelines for in-project documentation.
  • ./modules/timefield_taxonomy.module: The description on the line after the @param/@return documentation is either missing or not formatted correctly. See http://drupal.org/node/1354#functions
    43- */
    
  • ./timefield.module: The description on the line after the @param/@return documentation is either missing or not formatted correctly. See http://drupal.org/node/1354#functions
    420- */
    743- * the php date format
    745- * the integer value to be converted
    763- * time format that should be parsable via date_parse().
    781- * time format that should be parsable via date_parse().
    855- * The currentlt defined display settings, in PHP date() format.
    
  • Bad line endings were found, always use unix style terminators. See http://drupal.org/coding-standards#indenting
    ./js/jquery.ui.timepicker.min.js:             UTF-8 Unicode text, with very long lines, with no line terminators
    
    
  • All text files should end in a single newline (\n). See http://drupal.org/node/318#indenting
    ./modules/timefield_taxonomy.info ./css/jquery-ui-timepicker.css ./README.txt ./timefield.install ./js/jquery.ui.timepicker.min.js ./js/jquery.ui.timepicker.js ./theme/timefield-weekly-minical-box.tpl.php ./theme/timefield.tpl.php ./timefield.info ./views/timefield_plugin_style_minical.inc
    

This automated report was generated with PAReview.sh, your friendly project application review script. Go and review some other project applications, so we can get back to yours sooner.

Source: http://ventral.org/pareview - PAReview.sh online service

joachim’s picture

I just spotted a potential duplicate at http://drupal.org/project/cck_time

(Admittedly this proposal has the better module name now CCK is obsolete on D7...)

wesnick’s picture

Status: Needs work » Needs review
  1. I have moved code to branch 7.x-1.x
  2. Cleaned up code according to pareview
  3. Cleaned up code according to coder
  4. Update function documentation
  5. Updated README for line length

cck_time module is just a select element as textfield which stores times as a string in the database. This module does many more things, and as it stores times as integers, views filters and sorting becomes possible, so currently I would say there is no functionality overlap.

klausi’s picture

Status: Needs review » Needs work
StatusFileSize
new15.76 KB

Review of the 7.x-1.x branch:

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. Go and review some other project applications, so we can get back to yours sooner.

manual review:

  • jquery.ui.timepicker.js appears to be 3rd party code. 3rd party code is not generally allowed on Drupal.org and should be deleted. This policy is described in the getting involved handbook. It also appears in the terms and conditions you agreed to when you signed up for Git access, which you may want to re-read, to be sure you're not violating other terms. The Libraries API module is a recommended method for adding 3rd party dependencies without directly including the code on Drupal.org.
  • _timefield_time_part_format(): not all text in there is run through t().
  • Your views integration contains many debug statements and commented out code, please remove that. Also, drupalcs does not really like the Views coding style, you can ignore overridden method names that you cannot change.

Otherwise I think this is nearly ready.

wesnick’s picture

Status: Needs work » Needs review

Thanks @klausi for the review.

I have attended to everything you pointed out, as well as adding drush support for automatic downloading of the library.

Code Sniffer runs a tight ship, only wish the plugin fully worked on my Eclipse.

rudiedirkx’s picture

StatusFileSize
new10.97 KB
new25.26 KB

There's still a few imperfections: http://ventral.org/pareview/httpgitdrupalorgsandboxwesnick1168872git

And something I consider a bug:

  • These are my field instance settings:
    field instance settings
  • Which adds this to the input form:
    input form
    (which is acceptable, but incorrect IMO)
  • And the formatter result is also a 12 hour clock including "pm". (I've seen the formatter settings in the Manage Display tab: kudo's.) What does the "Show or Hide AM/PM" option do??
rudiedirkx’s picture

Status: Needs review » Needs work
wesnick’s picture

Status: Needs work » Needs review

@rudiedirkx, yes it was a bug, the "options" FAPI element turned these boolean values into strings and so were being added as "0" or "1" instead of true or false to js settings. Fixed in commit #24039a.

Also clarified what these input options are for with inline descriptions.

Added additional options supported by the timepicker widget. If you are updating from a previous version you will have to edit instance settings and save new options, lest you get undefined index errors. This will not happen on initial install since field_info has sensible defaults set.

Ran the code through coder, pareview, DrupalCodingStandards.

rudiedirkx’s picture

1. A few notices when I edit the node or time field instance, but they're gone after saving the field instance settings. (You added the closeButton etc options.)

2. But the problem persists: when I enter "14:00" in the field instance's Default Value textfield, I get "2:00pm" when I reload that page, and also when I edit or add a node with that field. "Show AM/PM Label" is unchecked (verified after saving).

3. The first sentence in your README is a little unclear: "Timefield is a Field API field that stores a time value, with an optional to time." Quotes around "to time" or renaming it to "end time" (like some other places) would help.

It's an obvious addition though. Three date fields in the date module, but no decent time fields. Good options too.

rudiedirkx’s picture

I've only now tried the included Timefield Taxonomy module. There's definitely not enough information, because I don't get it =)

  • I've created a vocabulary
  • I've added a time field to that vocabulary
  • I've created a term reference field in a node type linked to that vocabulary

And now what?

Can you make a list of steps the user has to follow to get the taxonomy part working? First step is enabling the module. Last step is adding or editing content.

wesnick’s picture

@rudiedirkx,

#17 -1: addressed in my previous post If you are updating from a previous version you will have to edit instance settings and save new options, lest you get undefined index errors. This will not happen on initial install since field_info has sensible defaults set.

#17 -2: I have synchronized input formats. Indeed there was a discrepancy between PHP date formatting and the jQuery plugin formatting; I was using the "display format" for default or previously existing values, which resulted in the anomaly you were experiencing. Now there exists an "input format" and a "display format" which are separate and consistent.

#17-3: Clarified readme file.

#18: I have removed the timefield_taxonomy module as I am not prepared to dive into bugfixing or extensive documentation for this yet. It works, but you are correct that I have to document it better. It is on a branch "timefield_taxonomy" if you wish to continue to experiment with it.

rudiedirkx’s picture

Just one more thing:

Timefield module provides a field type 'timefield' with a default JQuery widget.

Where do I get the jQuery plugin? A message after install or a constant warning or something like that might be nice to let the user know he's not quite done yet.

rudiedirkx’s picture

Status: Needs review » Reviewed & tested by the community

And then you're done IMO. Good module.

wesnick’s picture

Status: Reviewed & tested by the community » Needs review

It was showing up in the status reports section: admin/reports/status
If it is not installed there is a link to the site to install it.

However, I have added detailed instruction to the readme file.

wesnick’s picture

**DOUBLE POST**

rudiedirkx’s picture

Status: Needs review » Reviewed & tested by the community

Excellent.

You have committed a backup file README.txt~. You can set up you GIT so that it ignores all ~ files: http://help.github.com/ignore-files/

wesnick’s picture

Thanks for the heads-up, gedit leaves me these presents everywhere, it has been removed now.

klausi’s picture

Status: Reviewed & tested by the community » Fixed

manual review:
"_timefield_display_format_form('column_format', "Column Time Settings", $settings);": all user facing text should run through t() for translation. Also elsewhere.

But that is just a minor issue, so ...

Thanks for your contribution, wesnick! Welcome to the community of project contributors on drupal.org.

I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.

joachim’s picture

Congratulations!

(I've just hit your issue queue with a ton of minor bugs...! :D)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.