]> git.donarmstrong.com Git - lilypond.git/blob - input/lsr/adding-the-current-date-to-a-score.ly
Fix wrong menu
[lilypond.git] / input / lsr / adding-the-current-date-to-a-score.ly
1 %% Do not edit this file; it is auto-generated from LSR http://lsr.dsi.unimi.it
2 %% This file is in the public domain.
3 \version "2.11.48"
4
5 \header {
6   lsrtags = "titles"
7
8   texidoc = "
9 I often find it useful to include a date on printed music, so that I
10 can see if I'm using the latest version, or tell someone else that he
11 should only use the version after a certain date. A simple solution is
12 to enter the date manually to the @code{.ly} file. But that's very
13 error prone. It's easy to forget updating the date. So i thought it
14 would be useful if you can add the date on which the PDF file is
15 generated automatically. I did't figure it out myself, but I asked on
16 lilypond-user mailing list. And guess what? Someone came with an
17 excellent solution! So thank you very much Toine Schreurs for sending
18 this solution to the user mailing list. I post it here for future
19 reference.
20
21 The solution is to use two scheme functions called @code{strftime} and
22 @code{localtime}, as shown in the snippet. It is a very flexible
23 solution, you can format the date just as you like it by adapting the
24 @code{\"%d-%m-%Y\"} string. See the Guile documentation for more
25 details on this format string: Formatting Calendar Time. 
26
27 "
28   doctitle = "Adding the current date to a score"
29 } % begin verbatim
30 \version "2.11.48"
31 % first, define a variable to hold the formatted date:
32 date = #(strftime "%d-%m-%Y" (localtime (current-time)))
33
34 % use it in the title block:
35 \header {
36   title = "Including the date!"
37   subtitle = \date
38 }
39
40 \score {
41   \relative c'' {
42     c4 c c c
43   }
44 }
45 % and use it in a \markup block:
46 \markup {
47   \date
48 }