Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse fractional second #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Parse fractional second #5

wants to merge 2 commits into from

Conversation

mremond
Copy link

@mremond mremond commented Feb 8, 2015

I added the s library as a requirement. It is probably possible to do without it.
This is my first elisp patch, so I still need to learn ;)
This solve a problem I had with server that implement fractional second for more accurate message sorting.

However, @legoscia please, let me know if you have some tips to do without the slice command and I will update the PR.

Thanks !

I added the s library as a requirement. It is probably possible to do without it.
This is my first elisp patch, so I still need to learn ;)
MAM does send a timestamp even on new messages. For now notify all messages.
@legoscia
Copy link
Owner

Thanks for the patch! I think you could do this with split-string instead of s-slice-at, thus avoiding the need for an extra dependency.

Could you add a test case in the tests directory as well? Create a new file, parse-time.el, and add something like:

(unless (equal (jabber-parse-time "2015-02-07T15:56:17.12Z") '(21718 13729))
  (error "fractional time parse failed"))

Then add the file in tests/Makefile.am and test with make check.

I'll need to think about what to do about notifications vs history. In principle, all history comes before the room subject, and all fresh messages come after it (XEP-0045 section 7.2.16), but if the MUC server doesn't obey that and never sends a subject, we might end up never showing notifications, which would be bad. Perhaps a good heuristic would be to turn notifications on for a certain room whenever we see a timestamp within the last minute...

@legoscia
Copy link
Owner

Oh, a second test case would be a time stamp with fractional seconds and a time zone that's not Z.

@legoscia
Copy link
Owner

Hm wait, on further thought split-string is not the right function, since it drops the "separator". string-match and match-string are probably the way to go.

@mremond
Copy link
Author

mremond commented Feb 22, 2015

Thanks, that's good advice and good exercise or me to perfect my elisp learning :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants