bugzilla.mozilla.org has resumed normal operation. Attachments prior to 2014 will be unavailable for a few days. This is tracked in Bug 1475801.
Please report any other irregularities here.

consolidate all time stamp code

RESOLVED FIXED

Status

DevTools
General
P3
normal
RESOLVED FIXED
8 years ago
a month ago

People

(Reporter: ddahl, Assigned: ddahl)

Tracking

Trunk
x86
All
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 2 obsolete attachments)

(Assignee)

Description

8 years ago
Consolidate all time stamp code into a single function.
(Assignee)

Updated

8 years ago
Assignee: nobody → ddahl
(Assignee)

Updated

8 years ago
No longer blocks: 534398
(Assignee)

Updated

8 years ago
Blocks: 529086
(Assignee)

Updated

8 years ago
Priority: -- → P3
Created attachment 456304 [details] [diff] [review]
initial try for consolidating timestamp code

This is my try at consolidating the timestamp code.

What I decided is that messages need timestamps as integers - milliseconds from the UNIX epoch. They should not hold hard-coded strings, because this prevents one from quickly comparing two messages if one is older or newer than the other.

For displaying the timestamps I added a new method in ConsoleUtils: timestampString() which takes as input a date in the milliseconds format.

The localization issue is still there. I believe that timestamps should be displayed by code inside the HeadUpDisplay object instances, at runtime - message objects themselves should have no DOM nodes, and no hard-coded strings as they do now. The patch I provide is minimal, by not changing code related to the issue of how the GUI code works.

I bumped into this issue while working on bug 552143. I'll have to rely on message objects having an integer timestamp. I would not like to timestamp each message for a second time when the message is recorded in the console storage. I want to reuse the timestamp property from the message object itself.

Please let me know if I can improve the code further.

Thanks!
Attachment #456304 - Flags: review?(ddahl)

Updated

8 years ago
Blocks: 578658
Comment on attachment 456304 [details] [diff] [review]
initial try for consolidating timestamp code

in timestamp():
+    return (new Date()).getTime();

why not just use 

return Date.now(); ?

in timestampString():

+    return pad(d.getHours()) + ":"
+      + pad(d.getMinutes()) + ":"
+      + pad(d.getSeconds()) + ":"
+      + pad(d.getMilliseconds(), true);

pretty sure you're going to need a stringBundle and properly-defined hoursSeparator, minutesSeparator, secondsSeparator for l10n.
Comment on attachment 456304 [details] [diff] [review]
initial try for consolidating timestamp code

adding request for a mossop-flavored review.
Attachment #456304 - Flags: review?(dtownsend)
Created attachment 457583 [details] [diff] [review]
patch update 2

Thank you Robert for the review!

I updated the patch to use Date.now().

This patch, like the previous one, applies cleanly on mozilla-central and on ddahl's user repository.
Attachment #456304 - Attachment is obsolete: true
Attachment #457583 - Flags: review?
Attachment #456304 - Flags: review?(dtownsend)
Attachment #456304 - Flags: review?(ddahl)

Updated

8 years ago
Attachment #457583 - Flags: review? → review?(dietrich)
Comment on attachment 457583 [details] [diff] [review]
patch update 2

r=me, thanks!
Attachment #457583 - Flags: review?(dietrich) → review+
Whiteboard: [checkin-needed]
Created attachment 457910 [details] [diff] [review]
[checked-in] patch update 3 for mozilla-central

updated patch for mozilla-central, as requested by Robert.
Attachment #457583 - Attachment is obsolete: true
Comment on attachment 457910 [details] [diff] [review]
[checked-in] patch update 3 for mozilla-central

changeset:   47919:4989f8c0fdc3
user:        Mihai Sucan <robodesign@gmail.com>
date:        Mon Jul 19 10:51:51 2010 -0300
summary:     bug 568657 - consolidate all time stamp code
Attachment #457910 - Attachment description: patch update 3 for mozilla-central → [checked-in] patch update 3 for mozilla-central
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED

Comment 8

8 years ago
A small optimization option:
replace pad(x,mil) with pad(x) and padmil(x), to prevent the check for mil.

And why: new Date(ms ? ms : null); 
new Date(ms) should also work.
(In reply to comment #8)
> A small optimization option:
> replace pad(x,mil) with pad(x) and padmil(x), to prevent the check for mil.
> 
> And why: new Date(ms ? ms : null); 
> new Date(ms) should also work.

this has been checked in already. if you see improvements, please file a separate bug and attach your patch.

thanks!

Comment 11

8 years ago
Note, the checkin referred to in comment #9 is later than the comment stated 'this has been checked in already'.
Whiteboard: [checkin-needed]

Updated

a month ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.