Closed Bug 357324 Opened 14 years ago Closed 13 years ago

Date/Time Custom Fields


(Bugzilla :: Bugzilla-General, enhancement, P1)




Bugzilla 3.2


(Reporter: mkanat, Assigned: mkanat)


(Blocks 2 open bugs)



(1 file)

Some users want to have a field that stores a date and a time. It would be different than just a normal plain-text field because it would be stored as a datetime in the database (so that it sorts correctly) and it would be validated upon entry (to make sure that you couldn't enter an invalid date).

Everything except the validation is pretty simple.

It probably also ought to be formatted in some nice way, possibly by letting users choose a format. (We could add a "format" column to fielddefs, which could also be used as a regular expression for FIELD_TYPE_FREETEXT to validate the input.) I think that should be done in a separate bug, though. For now we should just require people to input the dates in the format that makes sense to their database.
The validation is pretty trivial, see Util::validate_date() and Util::format_time() to redisplay the date in the format you want.
and if the user has javascript available, a little calendar popup to pick a date off of and fill it in for you would be cool, too. :)
(In reply to comment #2)
> and if the user has javascript available, a little calendar popup to pick a
> date off of and fill it in for you would be cool, too. :)

  Yep, that's exactly the plan. We can use YUI for it.
Okay, so YUI doesn't have a time widget, only a date widget. So either we use a different library than YUI or we find an extension. I don't want to write our own time widget, that would be ridiculous.

Also, I'm not going to split every date field into two fields, one for date and the other for time, because that would complicate the code needlessly.
Blocks: 397098
Blocks: 397099
Blocks: 397102
Priority: -- → P1
Target Milestone: --- → Bugzilla 3.2
Attached patch v1Splinter Review
Okay, here it is. A very basic implementation.

  I have to say, Bugzilla's architecture is finally so nice that adding this field was an experience that went exactly like it should have. :-)
Assignee: general → mkanat
Attachment #285456 - Flags: review?(LpSolit)
Comment on attachment 285456 [details] [diff] [review]

>Index: template/en/default/bug/field.html.tmpl

>+    [% CASE constants.FIELD_TYPE_DATETIME %]
>+      <input name="[% FILTER html %]" size="20"
>+             value="[% value FILTER html %]">

Nit: I would love to see "(YYYY-MM-DD HH:mm:ss)" being displayed besides the date fields, so that the user has a chance to know which format to use. Else you have to wait to get both date and time errors to discover them.

r=LpSolit with or without my nit fixed.
Attachment #285456 - Flags: review?(LpSolit) → review+
Flags: approval+
I figure we can deal with formatting comments in bug 397102.
Checking in Bugzilla/;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/,v  <--
new revision: 1.212; previous revision: 1.211
Checking in Bugzilla/;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/,v  <--
new revision: 1.84; previous revision: 1.83
Checking in Bugzilla/;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/,v  <--
new revision: 1.29; previous revision: 1.28
Checking in Bugzilla/;
/cvsroot/mozilla/webtools/bugzilla/Bugzilla/,v  <--
new revision: 1.62; previous revision: 1.61
Checking in template/en/default/bug/field.html.tmpl;
/cvsroot/mozilla/webtools/bugzilla/template/en/default/bug/field.html.tmpl,v  <--  field.html.tmpl
new revision: 1.12; previous revision: 1.11
Checking in template/en/default/global/field-descs.none.tmpl;
/cvsroot/mozilla/webtools/bugzilla/template/en/default/global/field-descs.none.tmpl,v  <--  field-descs.none.tmpl
new revision: 1.25; previous revision: 1.24
Checking in template/en/default/global/user-error.html.tmpl;
/cvsroot/mozilla/webtools/bugzilla/template/en/default/global/user-error.html.tmpl,v  <--  user-error.html.tmpl
new revision: 1.235; previous revision: 1.234
Closed: 13 years ago
Resolution: --- → FIXED
Keywords: relnote
Added to the release notes for Bugzilla 3.2 in a patch on bug 432331.
Keywords: relnote
You need to log in before you can comment on or make changes to this bug.