Changeset 9 for trunk/Calendar/date2string.pro
- Timestamp:
- 04/26/06 16:29:38 (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Calendar/date2string.pro
r7 r9 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME: 5 ; NAME: date2string 6 6 ; 7 ; PURPOSE: 7 ; PURPOSE: create a nice and readable format to print a date 8 8 ; 9 ; CATEGORY: 9 ; CATEGORY: calendar/string 10 10 ; 11 ; CALLING SEQUENCE: 11 ; CALLING SEQUENCE: nice_date = date2string(yyyymmdd) 12 12 ; 13 ; INPUTS: 13 ; INPUTS: yyyymmdd the date in the format 14 ; yearyearyearyearmonthmonthdayday 14 15 ; 15 ; KEYWORD PARAMETERS: 16 ; KEYWORD PARAMETERS:those of string fonction to specify the 17 ; format of the month (the C format) 16 18 ; 17 ; OUTPUTS: 19 ; OUTPUTS: a string containing the date in a easy readable format 18 20 ; 19 ; COMMON BLOCKS: 21 ; COMMON BLOCKS:none 20 22 ; 21 ; SIDE EFFECTS: 23 ; SIDE EFFECTS:? 22 24 ; 23 ; RESTRICTIONS: 25 ; RESTRICTIONS:? 24 26 ; 25 27 ; EXAMPLE: 26 28 ; 29 ; IDL> print, date2string(19900123) 30 ; Jan 23, 1990 31 ; IDL> print, date2string(19900123, format = '(C(CMOA))') 32 ; JAN 23, 1990 33 ; 27 34 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 28 ; 35 ; Creation ??? 36 ; update/review June 2005 Sebastien Masson. 29 37 ;- 30 38 ;------------------------------------------------------------ 31 39 ;------------------------------------------------------------ 32 40 ;------------------------------------------------------------ 33 FUNCTION date2string, date41 FUNCTION date2string, yyyymmdd, _EXTRA = ex 34 42 ; 35 @common 36 ; 37 s_date = strtrim(date, 2) 38 length = strlen(s_date) 39 sday = strtrim(fix(strmid(s_date,length-2)), 1) 40 smonth = strmid(s_date,length-4, 2) 41 syear = strmid(s_date, 0 ,length-4) 42 ; res = syear+' '+string(format='(C(CMoA0))',31*(fix(smonth)-1))+' 43 ; '+sday 44 if n_elements(langage) EQ 0 then langage = 'gb' 45 case langage of 46 'gb':BEGIN 47 truc = long(sday) 48 truc = truc-truc/10*10 49 case truc of 50 2:truc = 'nd' 51 3:truc = 'rd' 52 ELSE:truc = 'th' 53 endcase 54 res = string(format='(C(CMoA0))',31*(fix(smonth)-1))+' the '+sday+truc+' '+syear 55 END 56 ELSE:res = sday+' '+string(format='(C(CMoA0))',31*(fix(smonth)-1))+' '+syear 57 endcase 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 58 48 return, res 59 49 end
Note: See TracChangeset
for help on using the changeset viewer.