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 | ; @returns a string containing the date in a easy readable format |
---|
15 | ; |
---|
16 | ; @examples |
---|
17 | ; |
---|
18 | ; IDL> print, date2string(19900123) |
---|
19 | ; Jan 23, 1990 |
---|
20 | ; IDL> print, date2string(19900123, format = '(C(CMOA))') |
---|
21 | ; JAN 23, 1990 |
---|
22 | ; |
---|
23 | ; @history Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
24 | ; Creation ??? |
---|
25 | ; update/review June 2005 Sebastien Masson. |
---|
26 | ;- |
---|
27 | ;------------------------------------------------------------ |
---|
28 | ;------------------------------------------------------------ |
---|
29 | ;------------------------------------------------------------ |
---|
30 | FUNCTION date2string, yyyymmdd, _EXTRA = ex |
---|
31 | ; |
---|
32 | ; |
---|
33 | compile_opt idl2, strictarrsubs |
---|
34 | ; |
---|
35 | sday = strtrim(long(yyyymmdd) MOD 100, 1) |
---|
36 | smonth = strtrim((long(yyyymmdd)/100) MOD 100, 2) |
---|
37 | syear = strtrim(long(yyyymmdd)/10000, 2) |
---|
38 | res = string(format = '(C(CMoa))', 31*(fix(smonth)-1), _EXTRA = ex) $ |
---|
39 | + ' ' + sday + ', ' + syear |
---|
40 | return, res |
---|
41 | end |
---|