{"thread":{"id":"60055","subject":"Feature request for shorter relative date format in log","startedAt":"2023-08-02T06:07:48Z","lastAt":"2023-08-04T18:25:12Z","messageCount":5,"participants":["Yucheng Zhou","Taylor Blau","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"480092","messageId":"ME3P282MB2274D11DC15DF1FDBBC36C3DBE0BA@ME3P282MB2274.AUSP282.PROD.OUTLOOK.COM","threadId":"60055","inReplyTo":null,"subject":"Feature request for shorter relative date format in log","fromName":"Yucheng Zhou","fromEmail":"zhouyucheng98@outlook.com","sentAt":"2023-08-02T06:07:16Z","receivedAt":"2023-08-02T06:07:48Z","isPatch":false,"sender":{"key":"zhouyucheng98@outlook.com","avatar":null},"body":"Hello there,\n\nI usually use --date=relative in git log, but I find it can be shorter to save more space and be more efficient. \n\nFirst, the trailing “ago” can be removed, because it seems every relative date has a trailing ago. \nSecond, the seconds, minutes, hours, days, weeks, months, and years can be shorten to a single letter (e.g., s, m, h, d, w, M, Y), and the suffix “s” for plural can also be removed in this case. \nMaybe it will be better to give us a way to customize it, or create a new to config like --date=relative-short.\n\nI apologize for any inconvenience since it’s my first time to use a mailing list.\n\nThanks."},{"id":"480099","messageId":"ZMqciat7tdbYGob8@nand.local","threadId":"60055","inReplyTo":"ME3P282MB2274D11DC15DF1FDBBC36C3DBE0BA@ME3P282MB2274.AUSP282.PROD.OUTLOOK.COM","subject":"Re: Feature request for shorter relative date format in log","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-08-02T18:12:25Z","receivedAt":"2023-08-02T18:12:30Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Aug 02, 2023 at 02:07:16PM +0800, Yucheng Zhou wrote:\n> Hello there,\n>\n> I usually use --date=relative in git log, but I find it can be shorter\n> to save more space and be more efficient.\n>\n> First, the trailing “ago” can be removed, because it seems every\n> relative date has a trailing ago.  Second, the seconds, minutes,\n> hours, days, weeks, months, and years can be shorten to a single\n> letter (e.g., s, m, h, d, w, M, Y), and the suffix “s” for plural can\n> also be removed in this case.  Maybe it will be better to give us a\n> way to customize it, or create a new to config like\n> --date=relative-short.\n\nI can't think of a way that this is possible to do currently.\n\nYou can customize the format of absolute dates by using\n`--date=format:xyz' where xyz is passed as an argument to the system's\nstrftime() implementation.\n\nBut we don't have a way for users to provide custom over relative dates.\nPerhaps we should?\n\nThanks,\nTaylor\n"},{"id":"480108","messageId":"xmqqsf915b54.fsf@gitster.g","threadId":"60055","inReplyTo":"ZMqciat7tdbYGob8@nand.local","subject":"Re: Feature request for shorter relative date format in log","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-08-02T22:31:51Z","receivedAt":"2023-08-02T22:31:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Taylor Blau <me@ttaylorr.com> writes:\n\n> But we don't have a way for users to provide custom over relative dates.\n\nAre there existing systems to format time durations in a customized\nway, just like strftime() is a way way to custom-format a timestamp,\nthat we can just use, or write our own modelling after them?\n\nThe relative-time code decides which points in the time durection\nspectrum are good places to switch the granularity (e.g. up to 90\nseconds we will give \"N seconds\", and up to 90 minutes we will give\n\"N minutes\").  You could grep in date.c:show_date_relative() for\nQ_() and _(), and place them in an array and allow them to be\nreplaced by strings in the configuration variable, but that will\ncover only one smaller half of the problem (i.e. how the \"N seconds\"\nare shown) and the other half (i.e. what variants there are, and\nwhich variant is used for what time duration---you cannot introduce\na rule that says \"up to 500 seconds, show 'N minutes M seconds'\").\n\nEven with that solution to the smaller half will also create i18n\nheadaches.\n\n> Perhaps we should?\n\nIt will be an interesting puzzle, if done well.  Even though my\ncriteria to consider that a solution is done \"well\" is not that\nhigh, it should at least allow defining your own variants.  Instead\nof the rules that are implemented as hardcoded if-statement cascade\nin date.c:show_date_relative(), it should allow you to say something\nlike\n\n    * For a timestamp that is N seconds into the future, format a\n      relative timestamp that is N seconds ago, and replace \"ago\"\n      with \"in the future\".\n\n    * For a timestamp that is less than 1200 seconds ago, show \"N\n      minutes M seconds ago\" (with appropriate pluralization for\n      \"minute\" and \"second\" when N and/or M is 1).\n\n    * For a timestamp that is less than 5 hours ago, show \"N hours M\n      minutes ago\" (ditto about plural).\n\nand so on.\n\nNo, I am not interested in working on such a solution myself.  But\nit will be an interesting puzzle.\n\n"},{"id":"480110","messageId":"MEYP282MB2280E174A5B4FFE11DDB5C40BE08A@MEYP282MB2280.AUSP282.PROD.OUTLOOK.COM","threadId":"60055","inReplyTo":"xmqqsf915b54.fsf@gitster.g","subject":"Re: Feature request for shorter relative date format in log","fromName":"Yucheng Zhou","fromEmail":"zhouyucheng98@outlook.com","sentAt":"2023-08-03T02:54:47Z","receivedAt":"2023-08-03T02:55:21Z","isPatch":false,"sender":{"key":"zhouyucheng98@outlook.com","avatar":null},"body":"Thank you for your reply!\n\nActually, I think there is no need to allow users to config the switching of granularity. The current relative format has already done a great job.\nWhat I want is, a handy way to show a shorter relative date (like the “--short” flag in git status). And the current switching of granularity should be reused.\n\nThe only thing need to be changed, is the vocabulary for representation. For example, the “2 minutes ago” can be represented in “2m”, and “10 days ago” to “10d”. \nIf both the past and future timestamps should be taken into account, we can use a prefix “-” and “+”  to distinguish them. But I think we hardly see a future timestamp in the git log output, so we can let the past timestamps un-prefixed and only prefix the future ones with a “+”, maybe.\n\nThe rationale of this feature is saving space in the output, to let more useful information be shown in one line.\nFor instance, many skilled git users use customized one-line formats in git log, such as “<hash> <date> <author> <title-line>”. Where the <date> can be shortened as much as possible to save space for other important things (especially using with --graph or --decorate). Therefore, a shorter relative date representation of no more than about 3 characters can be a great idea.\n\nTo achieve this, a new format like “relative-short” can be introduced. There is no need to let users config so many things. Since there already exists “--date=short” for short absolute date format and “--date=default-local” which consists of two words, I think a new option “--date=relative-short” with a well-designed shorter representation will be very handy and great.\n\n"},{"id":"480163","messageId":"ZM1Ccn766xge31Uo@nand.local","threadId":"60055","inReplyTo":"xmqqsf915b54.fsf@gitster.g","subject":"Re: Feature request for shorter relative date format in log","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2023-08-04T18:24:50Z","receivedAt":"2023-08-04T18:25:12Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"On Wed, Aug 02, 2023 at 03:31:51PM -0700, Junio C Hamano wrote:\n> Taylor Blau <me@ttaylorr.com> writes:\n>\n> > But we don't have a way for users to provide custom over relative dates.\n>\n> Are there existing systems to format time durations in a customized\n> way, just like strftime() is a way way to custom-format a timestamp,\n> that we can just use, or write our own modelling after them?\n\nI'm not aware of such a utility, no. I had imagined that we would\nrepresent the duration between two timestamps as another timestamp\noffset that same amount after the Epoch. Then the caller could specify a\nstrftime format string and format the \"duration\" that way.\n\n> The relative-time code decides which points in the time durection\n> spectrum are good places to switch the granularity (e.g. up to 90\n> seconds we will give \"N seconds\", and up to 90 minutes we will give\n> \"N minutes\").  You could grep in date.c:show_date_relative() for\n> Q_() and _(), and place them in an array and allow them to be\n> replaced by strings in the configuration variable, but that will\n> cover only one smaller half of the problem (i.e. how the \"N seconds\"\n> are shown) and the other half (i.e. what variants there are, and\n> which variant is used for what time duration---you cannot introduce\n> a rule that says \"up to 500 seconds, show 'N minutes M seconds'\").\n>\n> Even with that solution to the smaller half will also create i18n\n> headaches.\n\nYeah, I think mangling with those translation identifiers is going to be\na giant mess.\n\n> No, I am not interested in working on such a solution myself.  But\n> it will be an interesting puzzle.\n\nDitto ;-).\n\nThanks,\nTaylor\n"}]}