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)

2.23
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 3.0

People

(Reporter: mkanat, Assigned: mkanat)

References

Details

Attachments

(1 file, 1 obsolete file)

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.
Attached patch v1 (obsolete) — Splinter Review
Here's another pretty-easy one. I know that at least it compiles, and whine.pl seems to run without errors.
Assignee: erik → mkanat
Status: NEW → ASSIGNED
Attachment #221870 - Flags: review?(kevin.benton)
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 on attachment 221870 [details] [diff] [review] v1 OOPS - forgot r+
Attachment #221870 - Flags: review?(kevin.benton) → review+
Comment on attachment 221870 [details] [diff] [review] v1 LpSolit, want to do a little super-review on this?
Attachment #221870 - Flags: review?(LpSolit)
(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 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-
Attached patch v2Splinter Review
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 on attachment 222227 [details] [diff] [review] v2 r=LpSolit
Attachment #222227 - Flags: review?(LpSolit) → review+
Flags: approval?
Flags: approval? → approval+
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.

Attachment

General

Created:
Updated:
Size: