Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
24

You can use the copyright-update function. I would read the docs for the function. and others inside copyright.el for more info, but as a simple example, If I have: ;; Copyright (C) 2014, Jordon Biondo in a file and run copyright-update from the minibuffer, it updates the line to say ;; Copyright (C) 2014, 2015, Jordon Biondo You can have the function ...


8

Emacs's built-in date parser is parse-time-string in parse-time.el, called by date-to-time. It understands English month and weekday names and several combinations of elements in various orders, but not expressions like “next Wednesday”. The date input formats in the GNU date command provided on non-embedded Linux and Cygwin are implemented in the source of ...


8

TL;DR; From the keyboard (in org-mode): C-c . to activate (convert from inactive to active). C-c ! to inactivate (convert from active to inactive). From lisp: (org-time-stamp t) to activate, and (org-time-stamp t t) to inactivate. Edit: As Juancho points out, <S-up> and <S-down> both toggle between active and inactive timestamps.


6

Internally, org-mode uses the function org-read-date to do this: (org-read-date &optional ORG-WITH-TIME TO-TIME FROM-STRING PROMPT DEFAULT-TIME DEFAULT-INPUT INACTIVE) For example, (org-read-date nil nil "16 February 2015") returns "2015-02-16". This doesn't put in the "<>" or "[]" for active/inactive time-stamps, but you can easily add them with ...


6

You can use org-read-date to convert timestamp strings into internal times (org-read-date nil t "<2015-11-06>" nil) This can be compared to either (org-read-date nil t "today" nil) which always returns the current date or directly to the output of (current-time).


6

Sure such evil stuff is possible with elisp. But be warned. I am not aware of all the dark consequences that this evil piece of black art has. When you interactively run freeze-time you can input the date string at which you want to freeze the time. From then on time is frozen until you run release-time which undoes this science fiction scenario. Do not ...


6

Here's what I use: (when (fboundp 'copyright-update) (setq copyright-names-regexp "Monnier\\|Free Software") (add-hook 'before-save-hook #'copyright-update))


6

From the documentation of org-time-stamp: With two universal prefix arguments, insert an active timestamp with the current time without prompting the user. So eval the below: (org-time-stamp '(16) t) '(4) - one prefix arg (4) '(16) - two prefix args (4 * 4) '(64) - three prefix args (4 * 4 * 4) To read more about the universal arguments and ...


5

With a bit of guesswork: (org-insert-time-stamp (current-time))


5

The top of the EmacsWiki page on Display Time tells you how to control the format of the time. Of the three variables, it looks like display-time-format is the most relevant after inspecting the docstrings of the variables with C-h v display-time-format: String specifying format for displaying the time in the mode line. See the function format-time-...


5

The original poster may wish to have a look at the built-in function called calendar-count-days-region described in the manual: https://www.gnu.org/software/emacs/manual/html_node/emacs/Counting-Days.html The following is a custom function that uses the org-mode and calendar-mode libraries. Upon my examination of calendar-count-days-region, I saw that the ...


5

I write "<2016-06-15 Wed>--<2016-07-18 Mon>" ...and then (with POINT somewhere over the dates) I press C-c C-y (org-evaluate-time-range) C-ucy will write the time-range after the dates like, <2016-06-15 Wed>--<2016-07-18 Mon> 33d


5

You can use the apply function to pass a function arguments contained in a list as separate arguments. For example: (apply #'format "%04d-%02d-%02d" '(2017 8 21)) That way you can store the list in a variable or compute it with a function call, etc. (let ((best-day-ever '(2017 8 21))) (apply #'format "%04d-%02d-%02d" best-day-ever))


5

As lawlist mentioned in the comment, running the following in your own Emacs will return what you want (format-time-string "<%Y-%m-%d %a %H:%M:%S>" (seconds-to-time 1523473110)) ;; => "<2018-04-12 Thu 02:58:30>" (current-time-zone) ;; => (28800 "CST") As you can see my timezone is +08:00 or CST or Asia/Shanghai, you can also specific a ...


4

You need to define the variable org-time-stamp-custom-formats, not to call a function. What you type after the variable name and colon is a value (what you might type after '). -*- org-time-stamp-custom-formats: ("<%Y-%m>" . "<%Y-%m-%d %H:%M>") -*- or # Local Variables: # org-time-stamp-custom-formats: ("<%Y-%m>" . "<%Y-%m-%d %H:%M>...


4

parse-time-string parses "standard" time strings, as does org-parse-time-string. The documentation claims the latter will be faster. Neither gives a way to specify the format of the string. There is also an undocumented function parse-iso8601-time-string that parses ISO8601 into something. It isn't clear to me what the output is supposed to be.


4

Dates can be used in formulas. The following example should be similar to what you are asking for: | | | Date | Other | |---+----+--------------------+-------| | $ | | start=<2015-12-07> | | | # | 1 | <2015-12-14 Mon> | | | # | 2 | <2015-12-21 Mon> | | | # | 3 | <2015-12-28 Mon> | ...


4

This happens because org-insert-time-stamp inserts a time stamp (like the name says), but also returns the time stamp. Yasnippit inserts the return value but you're also left with the one inserted by the function call. A fix is to capture the return value, leaving only the inserted value: (let ((x (org-insert-time-stamp nil t t )))).


4

Base on your own answer, here is another way to do it. (require 'cal-iso) (defun iso-week-to-time (year week day) (pcase-let ((`(,m ,d ,y) (calendar-gregorian-from-absolute (calendar-iso-to-absolute (list week day year))))) (encode-time 0 0 0 d m y))) (format-time-string "%F" (iso-week-to-time 2018 32 2)) ;; => "...


3

Time zone informatian is not currently part of date formats in org-mode and thus not part of the output from C-c .. Like C-c C-c on a timestamp any extraneous material in the date specification is removed and the week day is corrected to fit a given date, so partial junk input like 13-6-3 Wed Xyz 13:00 is output as <2013-06-03 Mon 13:00> a ...


3

I came up with something like this: (defun my-format-time (time-string) (let* ((time (parse-time-string time-string)) (day (nth 3 time)) (month (nth 4 time)) (year (nth 5 time))) (format-time-string "<%Y-%m-%d>" ;; I would love to do an 'apply here, but the given list to be encoded contains nil which does n ...


3

As stated in a comment of mine underneath a similar / duplicate question by this original poster -- how to detect selection in date mode? -- the function org-read-date is the best choice: (insert (org-read-date)) The following example function demonstrates proposed usage of org-read-date based on the outline of the original poster: (defun insert-date-...


3

You can use the format-time-string function to format the time in different ways, for your example this should work: * TODO meditate SCHEDULED: `(format-time-string "<%Y-%m-%d %a 8:30am>" (current-time))`


3

See org-element-timestamp-parser (parses the timestamp at point, including the repeater part) and org-element-timestamp-interpreter (transforms a timestamp object back into Org syntax). For example, calling (org-element-timestamp-parser) with the point at the "<" of "<2016-01-25 Mon 14:51 +1w>" produces (timestamp (:type active :raw-...


3

The function you are looking for is file-attributes. The help text is fairly detailed but you will be wanting: 4. Last access time, as a list of integers (HIGH LOW USEC PSEC) in the same style as (current-time). (See a note below about access time on FAT-based filesystems.) 5. Last modification time, likewise. This is the time of the last change to the ...


3

Use the standard change hooks to record that information: https://www.gnu.org/software/emacs/manual/html_node/elisp/Change-Hooks.html#Change-Hooks If you record it, make sure it's in a buffer-local variable, so each buffer can have its own value. Here's a sample implementation: (defvar buffer-last-change-time nil "The last change time") (make-variable-...


3

The following will work: # Local Variables: # org-time-stamp-custom-formats: ("<%Y-%m>" . "<%Y-%m %H:%M>") # eval: (org-toggle-time-stamp-overlays) # End: Using (org-toggle-time-stamp-overlays) (C-cC-xC-t) to ensure they are properly displayed. You will need to confirm that these are safe local variables for them to apply however once they are ...


3

I think org habits is suitable for this task. Otherwise I actually don't see any problem with your current approach. They can indeed be regarded as three separate tasks anyways, since they're quite independent of each other, e.g. whether you watered on Monday doesn't have any impact on whether you'd still have to water it on Wednesday, so why not just leave ...


3

parse-iso8601-time-string already returns a time value that format-time-string accepts: (format-time-string "%Y-%m-%dT%H:%M:%S%z" (parse-iso8601-time-string "2011-01-23T16:18:46-08:00")) => "2011-01-24T08:18:46+0800"


3

The following code augments the key sequence M-w such that it copies the date below point with the format "%d.%m.%Y when region is not active ( %d: zero padded day, %m: zero-padded month, %Y: year). You can change the format with the customization option calendar-copy-as-kill-format. (defcustom calendar-copy-as-kill-format "%d.%m.%Y" "Format string for ...


Only top voted, non community-wiki answers of a minimum length are eligible