Closed (outdated)
Project:
Token
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
19 Oct 2008 at 22:21 UTC
Updated:
24 Apr 2024 at 18:48 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
christefano commentedComment #2
agharbeia commentedVery much needed for creating unique hackable URLs, or more precisely for creating more-likely-to-be unique URLs, which almost always works for a single user's site (i.e blog).
I hope this finds it way to the next release.
I searched and found this on the exact same day it was released!! What are the odds!
Comment #3
agharbeia commentedIs there something wrong with the curly bracket at line 14?
I get an error trying to apply the patch.
Comment #4
agharbeia commentedThe patch in the parent is no good:
First: It has no code for the i and s specifiers (minutes and econds)
Second: the code has the date() function formatter "H" for all the different hour formats advertised
See the atached patch instead.
On a side note, adding Swatch Internet time would also be nice for the purpose of creating URLs.
Comment #5
christefano commentedThanks for fixing those problems, agharbeia! I was in a big hurry when patching Token for our launch a few hours ago and ended up submitting a broken patch. #4 is perfect. I'd mark it RTBC but I'm not sure what you mean about "It has no code for the i and s specifiers (minutes and econds)." It's working for me.
Does anyone still use Swatch Internet Time?
Comment #6
agharbeia commentedWell, thanks to you, christefano, for giving me the lead. It's the first time I modified Drupal code and submitted a patch.
Regarding seconds and minutes, do you mean that you could see advertised tokens for these components in the original patch? I couldn't.
Internet time is cool if it's going to be used as part of a URL. Just as a pseudo-unique identifier to follow the date components where the the HHMMSS would have been placed, which is how I currently create nodes' paths.
Comment #7
christefano commentedSupport for seconds and minutes was added in #1 (and are in your improved version in #4) but were missing from the original post. Are they not appearing in your token lists (like the replacement list in Pathauto)?
I'm not sure how useful Swatch Internet Time would be as an identifier since each "beat" is about 1½ minutes. It's okay with me if you want to add it in new patch, though. Microseconds would be more useful for that, I think, but support for it is only in newer versions of PHP 5.
Comment #8
christefano commentedThe last patch didn't apply cleanly and had tabs instead of spaces. While rerolling it, I added support for Epoch (seconds since January 1, 1970) and rolled a patch for Token 6.x-1.x-dev.
Comment #9
lomz commentedWill ythis be implemented? I really miss theese tokens.
By the way, does this tokens work for comments?
Comment #10
christefano commentedNo, this patch is for token_node.inc but adding support in token_comment.inc is a pretty much a copy-and-paste job. Would you like to submit a patch?
Comment #11
lomz commentedShall look into it.
But it seems to be an error in the patch
And
Comment #12
lomz commentedCreated a patch, but it fails, could yyou help me figure out whats wrong?
I used diff -up as spesified in http://drupal.org/patch/create
I also added the entire new token_comment.inc
Comment #13
lomz commentedAlso adding my own token_comment.inc, with both the last changes I mentioned and #325227: Provide e-mail and commenter homepage tokens for comments.
Comment #14
lomz commentedAttaching patch without errors.
This patch is basicly the same as in #12.
Adds g, G, h, H, i, s, U for comments, has been tested for a week now.
Comment #15
lomz commentedAdded the original patch, corrected for comment 11:
http://drupal.org/node/323441#comment-1109915
I hope this can be added to -dev, so I dont need to remember to patch the file for every new update...
Comment #16
pkej commentedTested and working, both versions.
Comment #17
jorgeegomez commentedPatch applied cleanly to token-6.x-1.11. Changing the version of the bug.
Comment #18
lomz commentedIs there any news regarding the adding of this patch to release of the module?
Comment #19
lomz commentedDump
Comment #20
lomz commentedHere is my new editions of token_node and token_comment that reflects the patch for 6.x that is above.
I did not care for making a patch, but somebody can volunteer...
Comment #21
donquixote commentedsubscribe.
Also have a look at this one:
http://drupal.org/node/307520
For me the hours and minutes are more important, the refactoring can happen in a later stage.
Comment #22
donquixote commentedHere's a little module for those who can't wait and don't like to patch. I hope it works.
Comment #23
agharbeia commentedI just noticed that the date & time tokens are replaced by dates in the time zone of the server (in my case seemingly US/Pacific), even though /admin/settings/date-time is set to another time zone (in my case Africa/Cairo), and even after I added "date.timezone =Africa/Cairo" in php.ini
The displayed node creation time on the node itself is correct, however. Only those returned by the tokens are shifted.
For example see http://ahmad.gharbeia.org/2009/08/18/183437, which token-derived URL alias has a time different than the real creation time, which is displayed on the node itself as 2009/08/19 04:34.
Comment #24
sjovanig commentedI think this is a critical error...
Let's see... Following great work done by donquixote, I fixed a little this module.
Now it's using format_date instead date, and comments tokens has been fixed.
Here it's.
Comment #25
the.alphy commentedDoes anyone know the status of this and when it might be rolled into an official release? I agree with the lesergi that this is a critical fix. :)
Comment #26
jeffschulerHere's a patch for current 6.x-dev including the changes in #20.
Comment #27
jeffschulerI added AM/PM (and lowercase am/pm,) since a 12-hour clock is useless without it.
(...The list of date/time tokens could just keep growing. Could just have a [node:date-custom-????] token and allow for a php date format string...?)
I also changed the description for g, G, h, and H to "Node creation hour" instead of "Node creation time" to be consistent with the other choices. (Changed it for comment, too.)
Comment #28
joetsuihk commentedi think #27 patch do not fix what #23 and #24 is fixing about timezone
should replace date() with format_date()
Comment #29
danny_joris commentedDoes everyone agree that this is a critical error?
I would love to try some patches, but as I am not a developer, I don't know what errors I could look for in a patch.
I want to use time tokens for my comments in combination with the submitted_by module. In the meanwhile, I am going to experiment with the format_date api in the templates.
Comment #30
dave reidFeature requests are never critical.
Comment #31
perusio commentedThe above furnished patches don't apply to the current 6.x-1.x-dev. They're broken in several ways.
They don't use format_date and there's no need for a 'U' format, since token already provides a 'raw' date token that is none other than the Unix timestamp.
I attach a patch for providing, hours, minutes and seconds. I tested the mods with simpletest and it passed.
I hope it can be of use for other drupalers and to the token maintainers.
Thank you,
Comment #32
donquixote commentedAre you sure this applies to all 3 date formats? Date, datestamp and datetime (or how was it called)? I would imagine that "Date" "raw" is not a unix timestamp.
Comment #33
dave reidAs seen in the code,
$tokens[$token_prefix . 'raw'] = t("!description in UNIX timestamp format (1269441371)", array('!description' => $description));is the code re-used for any date tokens. date:raw is also the same token in D7.Comment #34
dave reidComment #36
perusio commentedThat's strange. It runs the tests in my dev site correctly. I don't understand the error. Is this a d.o testing setup related thing?
Attached are the test logs of the token_comment and token_node date tokens.
The images are somewhat messy, they're made with the only desktop based extension for chromium that captures all the webpage. But you can see above the stats of the tests: 0 fails in both cases. This was tested with the latest 6.x-1.x-dev version of token.
Thanks
Comment #37
perusio commentedOk, ok. I get. It's the patch --strip option. The test bot is expecting a diff generated by a VCS. I just did it the "paleolitic" way of copying files. Ok. I'll get this in git and generate a proper diff.
Thank you,
Comment #38
igor.ro commented#31: token_extra_date_tokens.patch queued for re-testing.
Comment #40
lonehorseend commentedSubscribing
Comment #41
perusio commentedFinally set up a git repository and generated a real patch.
Here it is.
Comment #42
perusio commentedComment #44
perusio commentedI don't get it. It works ok, the tests are passed. Isn't the patch against the current dev? Or is it against CVS HEAD?
Comment #45
techypaul commentedsub
Comment #46
jeffschulerIt should be against the current dev, yes, but the patch should be made from Drupal's root directory. Also, check out creating a patch from a git mirror to remove those a/b prefixes.
The "Review log" on the test details gives some indication of why things failed.
Patch in #41 re-rolled.
Comment #47
perusio commentedThank you Jeff. Now I understand how the patch must be generated.
António,
Comment #48
guidot commented#46: 323441-token_extra_date_tokens.patch queued for re-testing.
Comment #50
perusio commentedHere's a new version. The new dev version introduced the log related tokens and that shifted the lines a bit. That's why it failed.
Comment #51
perusio commentedI've setup a github repo for the patched version of token. Note that it's derived from token dev releases.
Here's the url: http://github.com/perusio/token.git
Comment #52
perusio commentedPatch re-rolled against latest dev.
Comment #53
perusio commentedRe-rolled.
Question: Do any of the maintainers have ideas about commiting this patch in to the dev release?
Thank you,
Comment #54
ionmedia commentedi find this page via google, because i can't find token for hor/minute for node cretion/moderation.
i can access $node object via php and convert UNIX dates, but token exists for simplyfication and i fink this functions must exist
please, add this tokens
Comment #55
jelo commentedHas the time zone issue as mentioned in #23 been addressed in general and standardized across all date tokens? I just ran into issues with CCK date fields and time zone conversion. Although I specified that no time zone conversion should happen, my dates are suddenly off by the time zone (the server is in Vancouver and the time zone is set to Vancouver)... Any time token that is in the morning between 0am-7am gets displayed as the day before. If I extend granularity of the date field to include hours and manually set it to 8am for example, the date gets displayed correctly.
Comment #56
newnewuser commentedapplied #53. working. thanks.
Comment #57
christefano commentedProvided that this is working properly, can someone change the status to "reviewed and tested" so that this can move forward? This issue is nearly four years old and it would be nice to see this patch get in.
Comment #58
perusio commentedWell I've mostly given up. I inquired twice about the patch getting in and never got a reply from the maintainer(s).
I can look into it and re-roll everything, but only if there's interest from the maintainer(s).
Comment #59
christefano commentedSure, this issue needs the attention of a project maintainer. Marking needs review.
I haven't tested #53 myself but it appears from the comments here that it's working. Can someone (newnewuser?) verify this and mark this "review and tested"?
Comment #61
rowbeast commentedsubscribe!
Comment #62
jorgeegomez commentedRe-rolling patch #53 by perusio.
Comment #63
dave reidCan we use something more self-descriptive than 'a' or 'A'? Maybe 'ampm' and 'AMPM'?
Otherwise this looks tested. Could use some people manually testing to confirm this works for them, and as well to screenshot what the token UI looks like with the large number of additional tokens.
Comment #64
mechler commentedaandAare the format that PHP provides for this value.See: PHP: date - Manual
Comment #65
jorgeegomez commentedRe-rolling patch #53 by perusio to current -dev, with more descriptive token names, as per #63
Comment #66
jorgeegomez commentedToken tries to use (slightly) more descriptive symbols than PHP pure (d,dd,ddd instead of j,d,D for instance)
Comment #67
jorgeegomez commentedScreenshot showing some of these new tokens being used. Sorry about some spanish-language strings in the UI.
Of course this table is several screens long, mostly due to every CCK field being there, in both -formatted and -raw options).
Comment #68
spazfoxPatch at #65 works great for me
Comment #69
scotwith1tworks great for me too. very useful tokens when you need them, thanks!
Comment #70
bluegeek9 commented