Closed
Bug 337782
Opened 19 years ago
Closed 19 years ago
Change the way that whine.pl gets and formats the current date
Categories
(Bugzilla :: Whining, enhancement)
Tracking
()
RESOLVED
FIXED
Bugzilla 3.0
People
(Reporter: mkanat, Assigned: mkanat)
References
Details
Attachments
(1 file, 1 obsolete file)
|
1.18 KB,
patch
|
LpSolit
:
review+
|
Details | Diff | Splinter Review |
Right now whine.pl does this to get info about the current date:
# get the current date and time from the database
$sth = $dbh->prepare('SELECT ' . $dbh->sql_date_format('NOW()', '%y,%m,%d,%a,%H,%i'));
$sth->execute;
my ($now_year, $now_month, $now_day, $now_weekdayname, $now_hour, $now_minute) = split(',', $sth->fetchrow_array);
$sth->finish;
That's basically the array version of localtime, with the day name added in. That's ridiculous.
Also, SQLite doesn't support a lot of those % format strings.
| Assignee | ||
Comment 1•19 years ago
|
||
Here's another pretty-easy one. I know that at least it compiles, and whine.pl seems to run without errors.
Comment 2•19 years ago
|
||
Comment on attachment 221870 [details] [diff] [review]
v1
Good patch. Very minor nit: Time::localtime specifies that localtime also returns yday and isdst. For clarity's sake, you may want to consider adding ", undef, undef" or ", $yday, $isdst" before ") = $localtime;"
Comment 3•19 years ago
|
||
Comment on attachment 221870 [details] [diff] [review]
v1
OOPS - forgot r+
Attachment #221870 -
Flags: review?(kevin.benton) → review+
| Assignee | ||
Comment 4•19 years ago
|
||
Comment on attachment 221870 [details] [diff] [review]
v1
LpSolit, want to do a little super-review on this?
Attachment #221870 -
Flags: review?(LpSolit)
| Assignee | ||
Comment 5•19 years ago
|
||
(In reply to comment #2)
> (From update of attachment 221870 [details] [diff] [review] [edit])
> you may want to consider adding ",
> undef, undef" or ", $yday, $isdst" before ") = $localtime;"
"undef" isn't an lvalue, and the others are just discarded. If I put vars there, perl would give me a "used only once" warning. :-)
Thanks for the review. :-)
Comment 6•19 years ago
|
||
Comment on attachment 221870 [details] [diff] [review]
v1
Here is the output I get with and without your patch applied and with the following line inserted:
print "YEAR: $now_year MONTH: $now_month DAY: $now_day DOW: $now_weekday
HOUR: $now_hour MIN: $now_minute\n";
./whine.pl
FROM DB:
YEAR: 06 MONTH: 05 DAY: 16 DOW: 2 HOUR: 17 MIN: 56
FROM localtime():
YEAR: 06 MONTH: 4 DAY: 16 DOW: 2 HOUR: 17 MIN: 56
Note that the month differs, because both MySQL and PostgreSQL return 5 for May, while localtime() returns 4 (0 = January, 11 = December for localtime(), see the docs).
So you have to either increment $now_month by 1 or fix
my @daysinmonth = qw(0 31 28 31 30 31 30 31 31 30 31 30 31);
to remove 0 from the first position (and fix all other places in whine.pl too). The first suggestion is safer, the last one is cleaner.
Attachment #221870 -
Flags: review?(LpSolit) → review-
| Assignee | ||
Comment 7•19 years ago
|
||
Ahh, good catch. I just incremented the month number; much easier with how the rest of the code works.
Attachment #221870 -
Attachment is obsolete: true
Attachment #222227 -
Flags: review?(LpSolit)
Comment 8•19 years ago
|
||
Comment on attachment 222227 [details] [diff] [review]
v2
r=LpSolit
Attachment #222227 -
Flags: review?(LpSolit) → review+
Updated•19 years ago
|
Flags: approval?
Updated•19 years ago
|
Flags: approval? → approval+
| Assignee | ||
Comment 9•19 years ago
|
||
Checking in whine.pl;
/cvsroot/mozilla/webtools/bugzilla/whine.pl,v <-- whine.pl
new revision: 1.24; previous revision: 1.23
done
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•