Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #28820
    David
    Participant

    If possible to use \J mode of Regular Expression or other way to calculate date or time in Emeditor? I tried to solve the problems I encountered, but had great challenges and was unsuccessful.

    Date calculation, Scenario 1.
    In a log file, there are many dates. I want to find two dates and calculate how many days have passed between them; or how many days have passed between them and the current date.

    Date calculation, Scenario 2.
    In a project planning file, there are many dates. I find a date and want to add or subtract the number of days from it to get a new date.

    Time calculation, Scenario 1.
    When creating subtitles for a movie, or lyrics for a song, it is common to include time. Sometimes it is necessary to add or subtract seconds or milliseconds to get new time.

    [00:38.50]Chroma
    [00:51.48]Lyrics: Zenith Tune: Qiu Gatso
    [01:13.48]Singing: Zewang Dorje
    [01:22.79]Lrc lyrics produced by: LA
    [01:25.90]
    [01:26.10]You have a name of a flower
    [01:30.45]Beautiful girl Zhuomala
    [01:34.63] You have the smile of a flower
    [01:38.57]Oh~ Beautiful girl Dromara
    [01:42.58] [01:42.58]
    [01:43.38] You’re like a free bird
    [01:47.64]singing in the grassland
    [01:51.81] You are like a butterfly in spring
    [01:56.07]Twinkling in the flowers

    Welcome your idea or suggestions. Thank you!

    #29090
    Yutaka Emura
    Keymaster

    Please write an example to each of your question (1 and 2) so that it will be easier to write an answer.

    As for Time calculation, Scenario 1, If you want to add 5.50 seconds to each time in your example, you can open the Replace dialog box, and enter:

    Find:
    (\d\d):(\d\d)\.(\d\d)

    Replace with:
    \J nAdd=550; n=parseInt("\1")*6000+parseInt("\2")*100+parseInt("\3")+nAdd; s=("0000"+(n % 6000)).substr(-4); ("00"+parseInt(n/6000)).substr(-2)+":"+s.substr(0,2)+"."+s.substr(2);

    and make sure the Regular Expressions option is turned on.

    You can replace nAdd=550 with the actual time you want to add in 10 milliseconds.

    #29093
    JohnQSmith
    Participant

    Replace with:
    \J nAdd=550; n=parseInt(“\1”)*6000+parseInt(“\2”)*100+parseInt(“\3”)+nAdd; s=(“0000″+(n % 6000)).substr(-4); (“00″+parseInt(n/6000)).substr(-2)+”:”+s.substr(0,2)+”.”+s.substr(2);

    THAT IS VERY COOL! This is my first time seeing it. Checking the version history in the help file puts it at version 18.4 (11 days shy of 4 years ago).

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.