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