1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; |
---|
6 | ; @file_comments create a nice and readable format to print a date |
---|
7 | ; |
---|
8 | ; @categories calendar, string |
---|
9 | ; |
---|
10 | ; @param yyyymmdd {in}{required} the date in the format yyyymmdd |
---|
11 | ; |
---|
12 | ; @file_comments keyword parameters of string function to specify the format of the month (the C format) can be used |
---|
13 | ; |
---|
14 | ; @keyword _EXTRA used to pass your keywords to the created procedure. |
---|
15 | ; |
---|
16 | ; @returns a string containing the date in a easy readable format |
---|
17 | ; |
---|
18 | ; @examples |
---|
19 | ; |
---|
20 | ; IDL> print, date2string(19900123) |
---|
21 | ; Jan 23, 1990 |
---|
22 | ; IDL> print, date2string(19900123, format = '(C(CMOA))') |
---|
23 | ; JAN 23, 1990 |
---|
24 | ; |
---|
25 | ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
26 | ; Creation ??? |
---|
27 | ; update/review June 2005 Sebastien Masson. |
---|
28 | ; |
---|
29 | ; @version $Id$ |
---|
30 | ; |
---|
31 | ;- |
---|
32 | ;------------------------------------------------------------ |
---|
33 | ;------------------------------------------------------------ |
---|
34 | ;------------------------------------------------------------ |
---|
35 | FUNCTION date2string, yyyymmdd, _EXTRA = ex |
---|
36 | ; |
---|
37 | ; |
---|
38 | compile_opt idl2, strictarrsubs |
---|
39 | ; |
---|
40 | sday = strtrim(long(yyyymmdd) MOD 100, 1) |
---|
41 | smonth = strtrim((long(yyyymmdd)/100) MOD 100, 2) |
---|
42 | syear = strtrim(long(yyyymmdd)/10000, 2) |
---|
43 | res = string(format = '(C(CMoa))', 31*(fix(smonth)-1), _EXTRA = ex) $ |
---|
44 | + ' ' + sday + ', ' + syear |
---|
45 | return, res |
---|
46 | end |
---|