FreeBASIC  0.91.0
intl_getweekdayname.c
Go to the documentation of this file.
1 /* get weekday name */
2 
3 #include "fb.h"
4 
5 static const char *pszWeekdayNamesLong[7] = {
6  "Sunday",
7  "Monday",
8  "Tuesday",
9  "Wednesday",
10  "Thursday",
11  "Friday",
12  "Saturday"
13 };
14 
15 static const char *pszWeekdayNamesShort[7] = {
16  "Sun",
17  "Mon",
18  "Tue",
19  "Wed",
20  "Thu",
21  "Fri",
22  "Sat"
23 };
24 
25 /*:::::*/
26 FBSTRING *fb_IntlGetWeekdayName( int weekday, int short_names, int disallow_localized )
27 {
28  FBSTRING *res;
29 
30  if( weekday < 1 || weekday > 7 )
31  return NULL;
32 
33  if( fb_I18nGet() && !disallow_localized ) {
34  res = fb_DrvIntlGetWeekdayName( weekday, short_names );
35  if( res!=NULL )
36  return res;
37  }
38  if( short_names ) {
39  res = fb_StrAllocTempDescZ( pszWeekdayNamesShort[weekday-1] );
40  } else {
41  res = fb_StrAllocTempDescZ( pszWeekdayNamesLong[weekday-1] );
42  }
43  if( res==&__fb_ctx.null_desc )
44  return NULL;
45  return res;
46 }