1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME: date2string |
---|
6 | ; |
---|
7 | ; PURPOSE: create a nice and readable format to print a date |
---|
8 | ; |
---|
9 | ; CATEGORY: calendar/string |
---|
10 | ; |
---|
11 | ; CALLING SEQUENCE: nice_date = date2string(yyyymmdd) |
---|
12 | ; |
---|
13 | ; INPUTS: yyyymmdd the date in the format |
---|
14 | ; yearyearyearyearmonthmonthdayday |
---|
15 | ; |
---|
16 | ; KEYWORD PARAMETERS:those of string fonction to specify the |
---|
17 | ; format of the month (the C format) |
---|
18 | ; |
---|
19 | ; OUTPUTS: a string containing the date in a easy readable format |
---|
20 | ; |
---|
21 | ; COMMON BLOCKS:none |
---|
22 | ; |
---|
23 | ; SIDE EFFECTS:? |
---|
24 | ; |
---|
25 | ; RESTRICTIONS:? |
---|
26 | ; |
---|
27 | ; EXAMPLE: |
---|
28 | ; |
---|
29 | ; IDL> print, date2string(19900123) |
---|
30 | ; Jan 23, 1990 |
---|
31 | ; IDL> print, date2string(19900123, format = '(C(CMOA))') |
---|
32 | ; JAN 23, 1990 |
---|
33 | ; |
---|
34 | ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
35 | ; Creation ??? |
---|
36 | ; update/review June 2005 Sebastien Masson. |
---|
37 | ;- |
---|
38 | ;------------------------------------------------------------ |
---|
39 | ;------------------------------------------------------------ |
---|
40 | ;------------------------------------------------------------ |
---|
41 | FUNCTION date2string, yyyymmdd, _EXTRA = ex |
---|
42 | ; |
---|
43 | sday = strtrim(long(yyyymmdd) MOD 100, 1) |
---|
44 | smonth = strtrim((long(yyyymmdd)/100) MOD 100, 2) |
---|
45 | syear = strtrim(long(yyyymmdd)/10000, 2) |
---|
46 | res = string(format = '(C(CMoa))', 31*(fix(smonth)-1), _EXTRA = ex) $ |
---|
47 | + ' ' + sday + ', ' + syear |
---|
48 | return, res |
---|
49 | end |
---|