[jina_monthName]

Description

Link: [jina_monthName]
Author: Jolle Carlestam
Category: Date
Version: 8.5.x
License: Public Domain
Posted: Jul. 08, 2007
Updated: Jan. 01, 0001
More by this author...
Returns the full month name for a given date. Supported languages are: Danish, Dutch, English, Finnish, French, German, Irish Gaelic, Italian, Norwegian, Portuguese, Spanish, Swedish, Greek, Chinese. Month names are capitalised in the format that's the language standard. For English August is returned as August, for Swedish it's returned as augusti. Returned format can be modified using the optional -case. Supported cases are 'word|sentence|lower|upper'.

Parameters

-date date, required date
-language string, optional 'en|sv|de|fr|it|es|nl|ga|fi|no|da|pt|el|zh'
-case string, optional 'word|sentence|lower|upper'

Sample Usage

var:'thismonth' = (jina_monthName: date, -language = 'sv');

	To change case from the language standard use -case:
	var:'thismonth' = (jina_monthName: date, -language = 'sv', -case = 'word|sentence|lower|upper');
						

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?LassoScript
/*
Returns the month name for a given date in a given language.

	{fileName=		jina_monthName.lasso }
	{rsrcType=		tag }
	{rsrcName=		jina_monthName }

	{lassoVrsnMin=		8.1.0 }
	{lassoVrsnMax=		8.5.2 }

	{author=			Jolle Carlestam }
	{authorEmail=		info@jina.se }
	{authorHTTP=		jina.se }

	{desc=			Translates month names into chosen language,
					datevalue needs to be a valid Lasso date. }

	{maintvsrn=		1.2 }
	{maintrelease=		1.0.0 }
	{maintdate=		2007-07-07 }
	{maintauthor=		Jolle Carlestam }
	{maintnotes=		Added several languages. Added check for wrong country
					codes for Swedish, Gaelic and Danish}

	{maintvsrn=		1.1.1 }
	{maintrelease=		1.0.0 }
	{maintdate=		2007-07-05 }
	{maintauthor=		Jolle Carlestam }
	{maintnotes=		Added case handling. Removed obsolete date error 
					handling}

	{maintvsrn=		1.1 }
	{maintrelease=		1.0.0 }
	{maintdate=		2007-01-30 }
	{maintauthor=		Jolle Carlestam }
	{maintnotes=		fixed bug not handling English, separated into its
					own file
					Added error handling if malformed date is used
					changed to select}

	{maintvsrn=		1.0 }
	{maintrelease=		1.0.0 }
	{maintdate=		2005-01-25 }
	{maintauthor=		Jolle Carlestam }
	{maintnotes=		initial release }

............................................................................

	Usage:

	var:'thismonth'=(jina_monthName: date, -language = 'sv');

	To change case from the language standard use -case:
	var:'thismonth' = (jina_monthName: date, -language = 'sv', -case = 'word|sentence|lower|upper');

.............................................................................

*/
Define_Tag: 'monthName',
	-namespace = 'jina_',
	-req = 'date', -type = 'date', -copy,
	-opt = 'language', -type = 'string',
	-opt = 'case', -type = 'string',
	-priority = 'replace',
	-description = 'Outputs a given dates month name in chosen language.'
;

	!local_defined('language') ? local('language' = 'en');
	!local_defined('case') ? local('case' = 'ignore');

// If a user supplies older and incorrect country codes change them to the correct value
	#language == 'se' ? #language = 'sv';
	#language == 'dk' ? #language = 'da';
	#language == 'ie' ? #language = 'ga';

	if(!(array('da', 'de', 'en', 'el', 'es', 'fi', 'fr', 'ga', 'it', 'nl', 'no', 'pt', 'sv', 'zh') >> #language));
		Fail: 8010, 'Unsupported language: ' + #language;
	/if;

	local:'month'= (#date->Month);

	select:  #language;
		case: 'sv'; // Swedish
			local: 'monthNames'=(Map: 1='januari', 2='februari', 3='mars', 4='april', 5='maj', 6='juni', 7='juli', 8='augusti', 9='september', 10='oktober', 11='november', 12='december');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'da'; // Danish
			local: 'monthNames'=(Map: 1='januar', 2='februar', 3='marts', 4='april', 5='maj', 6='juni', 7='juli', 8='august', 9='september', 10='oktober', 11='november', 12='december');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'de'; // German
			local: 'monthNames'=(Map: 1='Januar', 2='Februar', 3='März', 4='April', 5='Mai', 6='Juni', 7='Juli', 8='August', 9='September', 10='Oktober', 11='November', 12='Dezember');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'el'; // Greek
			local: 'monthNames'=(Map: 1='', 2='', 3='', 4='', 5='', 6='', 7='', 8='', 9='', 10='', 11='', 12='');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'es'; // Spanish
			local: 'monthNames'=(Map: 1='enero', 2='febrero', 3='marzo', 4='abril', 5='mayo', 6='junio', 7='julio', 8='agosto', 9='septiembre', 10='octubre', 11='noviembre', 12='diciembre');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'fi'; // Finnish
			local: 'monthNames'=(Map: 1='tammikuu', 2='helmikuu', 3='maaliskuu', 4='huhtikuu', 5='toukokuu', 6='kesäkuu', 7='heinäkuu', 8='elokuu', 9='syyskuu', 10='lokakuu', 11='marraskuu', 12='joulukuu');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'fr'; // French
			local: 'monthNames'=(Map: 1='janvier', 2='février', 3='mars', 4='avril', 5='mai', 6='juin', 7='juillet', 8='août', 9='septembre', 10='octobre', 11='novembre', 12='décembre');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'ga'; // Irish Gaelic
			local: 'monthNames'=(Map: 1='Eanáir', 2='Feabhra', 3='Márta', 4='Aibreán', 5='Bealtaine', 6='Meitheamh', 7='Iúil', 8='Lúnasa', 9='Meán', 10='Fómhair', 11='Deireadh', 12='Fómhair Samhain Nollaig');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'it'; // Italian
			local: 'monthNames'=(Map: 1='gennaio', 2='febbraio', 3='marzo', 4='aprile', 5='maggio', 6='giugno', 7='luglio', 8='agosto', 9='settembre', 10='ottobre', 11='novembre', 12='dicembre');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'nl'; // Dutch
			local: 'monthNames'=(Map: 1='januari', 2='februari', 3='maart', 4='april', 5='mei', 6='juni', 7='juli', 8='augustus', 9='september', 10='oktober', 11='november', 12='december');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'no'; // Norwegian
			local: 'monthNames'=(Map: 1='januar', 2='februar', 3='mars', 4='april', 5='mai', 6='juni', 7='juli', 8='august', 9='september', 10='oktober', 11='november', 12='desember');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'pt'; // Portuguese
			local: 'monthNames'=(Map: 1='Janeiro', 2='Fevereiro', 3='Março', 4='Abril', 5='Maio', 6='Junho', 7='Julho', 8='Agosto', 9='Setembro', 10='Outubro', 11='Novembro', 12='Dezembro');
			local:'monthName'= #monthNames->(Find: #month);
		case: 'zh'; // Chinese
			local: 'monthNames'=(Map: 1='', 2='', 3='', 4='', 5='', 6='', 7='', 8='', 9='', 10='', 11='', 12='');
			local:'monthName'= #monthNames->(Find: #month);
		case; // Can only be English
			local:'monthName'=(#date->Month: -long);
	/select;

	select: #case;
		case: 'word'; // All words start with a capital: Mars
			#monthName -> titleCase;
		case: 'sentence'; // First word start with a capital: Mars
			#monthName -> lowerCase;
			#monthName -> (ToTitle:1);
		case: 'lower'; // All words in lower case: mars
			#monthName -> lowerCase;
		case: 'upper'; // All words in upper case: MARS
			#monthName -> upperCase;
	/select;

	Return:#monthName;
/Define_Tag;
	
?>

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular