Results 1 to 7 of 7

Thread: 7.4.2 - Have you ever wanted a BS-free time format in mc?

  1. #1
    Member registered user
    Join Date
    Oct 2004
    Posts
    32

    7.4.2 - Have you ever wanted a BS-free time format in mc?

    Ever since 2008 when I started using Knoppix 5.3.1 (heavily remastered) I was stunned by the really obfuscating style of displaying access/modify/change time for files in mc.

    Simply looking at the whole column of time in a panel in mc is bound to get someone in a mental institution.

    I never understood the process of thinking on this aspect of the programmers who wrote this piece of software, otherwise very very useful.

    When it comes to representation of time, the only format that makes sense to me is "YYYY-mm-dd HH:MM".

    (Right, the year needs all 4 digits, anyone trying to tell me otherwise is missing some critical lamps. And the format having "day/month/year" is really retarded, especially when the year has only 2 digits and it's impossible to tell which is the month and which is the day and which is the year!! That is really really stupid, I'm sorry but there's just no other way of saying it.)

    Why "YYYY-mm-dd HH:MM"? Simply because it sorts itself out naturally timewise by means of regular alphabetical sorting if used in any indexing system.

    For instance I scan all my receipts from stores and save them in my data storage. And guess what the format of the file name is? "YYYY-mm-dd HH.MM Store_Name.tif"

    Simply displaying them in konqueror or any file manager they get sorted temporally by themselves.

    Quite a while ago I dug up the sources for mc-4.6.1 and started looking for a way to change the display format.
    I came up with a patch (see attachments to this message) which successfully gave me the time format displayed the way I wanted in mc.

    So now, since I started using Knoppix 7.4.2 it crossed my mind this would be the next nice trick to do in it.

    So here's what I did:
    (NOTE: everything described below is being done as root under the original Knoppix 7.4.2 DVD Live environment)

    Open a konsole window as root in an empty directory (for instance /home/knoppix/Downloads).
    Do the following:

    Code:
    sed -i -e "s/\.de\./.us./g" /etc/apt/sources.list
    rm -fv /var/cache/apt/*.bin
    rm -fv /var/lib/apt/lists/*debian*
    apt-get update
    Just for the record, I executed the code above on 2015 Jan 02. (It matters since at some point in the future the list of available package versions will change and the above code will have different consequences).

    Then I downloaded two packages from snapshot.debian.org:

    Code:
    wget http://snapshot.debian.org/archive/debian/20140317T222027Z/pool/main/libg/libgcrypt20/libgcrypt20-dev_1.6.1-2_i386.deb
    wget http://snapshot.debian.org/archive/debian/20140903T220917Z/pool/main/libs/libssh2/libssh2-1-dev_1.4.3-4_i386.deb
    Then I downloaded the sources for the version of mc in Knoppix 7.4.2:

    Code:
    wget http://snapshot.debian.org/archive/debian/20140402T100841Z/pool/main/m/mc/mc_4.8.12-1.debian.tar.xz
    wget http://snapshot.debian.org/archive/debian/20140402T100841Z/pool/main/m/mc/mc_4.8.12-1.dsc
    wget http://snapshot.debian.org/archive/debian/20140402T100841Z/pool/main/m/mc/mc_4.8.12.orig.tar.xz
    Then I made up a patch for the sources, that changes the time display format in mc's panels to what I described above.
    You can download it from the attachments to this message (mc-4.8.12-BS-free_time_format.patch.gz).

    Also you will need a script I prepared (update.sh) which looks like this:

    Code:
    #!/bin/sh
    
    #### RUN THIS AS ROOT !!!!! #####
    
    # src/setup.c lines 216 & 217 changed from:
    #define FMTYEAR _("%b %e  %Y")
    #define FMTTIME _("%b %e %H:%M")
    #                      to:
    #define FMTYEAR _("%Y-%m-%d %H:%M")
    #define FMTTIME _("%Y-%m-%d %H:%M")
    # (but it turns out it works without this, so it's not necessary)
    
    # lib/timefmt.c line 81 changed from:
    #    return i18n_timelength_cache
    #                to:
    #    return 16;
    
    # lib/timefmt.c line 114 changed from:
    #    return i18n_timelength_cache
    #                 to:
    #    return 16;
    
    # lib/timefmt.c line 139 changed from:
    #    FMT_LOCALTIME (timebuf, sizeof (timebuf), fmt, when);
    #                 to:
    #    FMT_LOCALTIME (timebuf, sizeof (timebuf), _("%Y-%m-%d %H:%M"), when);
    
    
    # Install dependencies required by the (re)building process.
    # At the time of running this script I had run "apt-get update" on 2015-Jan-02
    # after previously deleting /var/cache/apt/*.bin and /var/lib/apt/lists/*debian*
    echo -e "\n\n-------- removing libgnutls-dev ---------\n"
    apt-get -y remove libgnutls-dev
    echo -e "\n\n-------- removing libgcrypt11-dev ---------\n"
    apt-get -y remove libgcrypt11-dev
    echo -e "\n\n-------- installing libgcrypt20-dev ---------\n"
    dpkg -i libgcrypt20-dev_1.6.1-2_i386.deb
    echo -e "\n\n-------- installing libssh2-1-dev ---------\n"
    dpkg -i libssh2-1-dev_1.4.3-4_i386.deb
    echo -e "\n\n-------- installing a whole bunch ---------\n"
    apt-get -y install dh-autoreconf autopoint intltool bison check e2fslibs-dev libaspell-dev libgpm-dev libslang2-dev
    
    echo -e "\n\n-------- extracting mc-4.8.12 sources ---------\n"
    dpkg-source -x mc_4.8.12-1.dsc
    cd mc-4.8.12
    # now change src/setup.c and lib/timefmt.c as described above
    echo -e "\n\n-------- applying patch ---------\n"
    patch -p1 <../mc-4.8.12-BS-free_time_format.patch
    echo -e "\n\n-------- committing changes ---------\n"
    dpkg-source --commit
    echo -e "\n\n-------- rebuilding mc-4.8.12 debian packages ---------\n"
    dpkg-buildpackage -us -uc
    
    echo -e "\n\n-------- (re)installing mc-4.8.12 debian packages ---------\n"
    cd ..
    dpkg -i *.deb
    
    exit 0
    Copy/Paste the code above in kwrite and save it as "update.sh" in the same dir as the rest of the files.
    So at this point, your directory should look like this:

    Code:
    knoppix@Microknoppix:~/Downloads$ ls -1
    libgcrypt20-dev_1.6.1-2_i386.deb
    libssh2-1-dev_1.4.3-4_i386.deb
    mc_4.8.12-1.debian.tar.xz
    mc_4.8.12-1.dsc
    mc-4.8.12-BS-free_time_format.patch
    mc_4.8.12.orig.tar.xz
    update.sh
    Now simply type:

    Code:
    . update.sh
    or make the "update.sh" file executable and run it.

    It should run flawlessly until the end and when it's done, your directory should look like this:

    Code:
    knoppix@Microknoppix:~/Downloads$ ls -1
    libgcrypt20-dev_1.6.1-2_i386.deb
    libssh2-1-dev_1.4.3-4_i386.deb
    mc-4.8.12
    mc_4.8.12-1.debian.tar.xz
    mc_4.8.12-1.dsc
    mc_4.8.12-1_i386.changes
    mc_4.8.12-1_i386.deb
    mc-4.8.12-BS-free_time_format.patch
    mc_4.8.12.orig.tar.xz
    mc-data_4.8.12-1_all.deb
    mc-dbg_4.8.12-1_i386.deb
    update.sh
    Of course you can save the *.deb files somewhere and include them later in a Knoppix 7.4.2 remaster permanently.

    Now you can just type mc and you should see something like the snapshot attached to this message.

    Of course, first you need to go in mc's menu at "Left" or "Right" or both and change the "Listing mode" for panels to "User defined" (include "mtime" or "atime" or "ctime" somewhere in there) otherwise the time column won't be displayed.

    For instance this is what I had for "User defined" "Listing mode" when I took the snapshot:

    Code:
    half type name | size | mtime | perm | owner | group
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    Moderator Moderator
    Join Date
    Nov 2010
    Location
    Germany/ Dietzenbach
    Posts
    1,124
    Quite a while ago I dug up the sources for mc-4.6.1 and started looking for a way to change the display format.
    I came up with a patch (see attachments to this message) which successfully gave me the time format displayed the way I wanted in mc.
    The other way is to edit the lines "timeformat..." to "..=%F %R" (man strftime) within '../.config/mc/ini' for the user knoppix and for root. Close the terminal and start again a terminal to have the changed datetime format.

  3. #3
    Senior Member
    Join Date
    Dec 2012
    Posts
    151
    @ Werner

    Is there a way to achieve that change of time & date formats for PCManFM?

    Regards

  4. #4
    Member registered user
    Join Date
    Oct 2004
    Posts
    32
    Quote Originally Posted by Werner P. Schulz View Post
    The other way is to edit the lines "timeformat..." to "..=%F %R" (man strftime) within '../.config/mc/ini' for the user knoppix and for root. Close the terminal and start again a terminal to have the changed datetime format.
    Wow! Stunning! I had no idea they introduced this feature! It wasn't there in mc-4.6.2!

    I just tested it and it doesn't work there.
    They must have added it afterwards, but I was just assumimg brute force was still needed.

    I did what you described here in K7.6.2 and it works great.
    Nice to know you don't need to kick the door open because the handle actually works...

    If you had not told me about this, I would have never known!
    I was just going to assume the dumbness would stay there forever...

  5. #5
    Moderator Moderator
    Join Date
    Nov 2010
    Location
    Germany/ Dietzenbach
    Posts
    1,124
    Some years ago the team of developers has changed

  6. #6
    Moderator Moderator
    Join Date
    Nov 2010
    Location
    Germany/ Dietzenbach
    Posts
    1,124
    Is there a way to achieve that change of time & date formats for PCManFM?
    As I can see it's hardcoded within PCManFM only to use the locale settings.

  7. #7
    Member registered user
    Join Date
    Oct 2004
    Posts
    32
    By the way, my preference for now is to use LXDE, but not with Metacity as a window manager.
    I use Kwin (I modified the entry in /home/knoppix/.config/lxsession/LXDE/{config,desktop.conf}).
    And while I'm at it, I also use Konqueror instead of pcmanfm, I find pcmanfm too primitive.
    With konqueror I can customize the context menu to add my own actions backed by scripts...

    And things like time and date are easy to set in KDE System Settings, other things are still hackable...

    I tried for curiosity's sake to look in the sources for the place to hack in order to change the time & date format, but I couldn't figure out an exact place or way and I don't have too much time on my hands to dig.
    Maybe asking the programmer would be the best and quickest way to figure, like I did with konqueror.
    Last edited by chris_Xnest; 01-04-2015 at 03:03 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •