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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
<?LassoScript
/*
Returns the day name for a given date in a given language.
{fileName = jina_dayName.lasso }
{rsrcType = tag }
{rsrcName = jina_dayName }
{lassoVrsnMin = 8.1.0 }
{lassoVrsnMax = 8.5.3 }
{author = Jolle Carlestam }
{authorEmail = info@jina.se }
{authorHTTP = jina.se }
{desc = Translates day names into chosen language,
-date needs to be a valid Lasso date. }
{maintvsrn = 1.3.4 }
{maintrelease = 1.0.0 }
{maintdate = 2007-07-04 }
{maintauthor = Jolle Carlestam }
{maintnotes = Corrected wrong country codes for Swedish, Danish and
Irish Gaelic.Should be sv, da and ga. Added Chinese and Greek
(Thanks Bil Corry!)}
{maintvsrn = 1.3.3 }
{maintrelease = 1.0.0 }
{maintdate = 2007-07-04 }
{maintauthor = Jolle Carlestam }
{maintnotes = Added more languages. Added support for case handling
-case = 'word|sentence|lower|upper'}
{maintvsrn = 1.3.2 }
{maintrelease = 1.0.0 }
{maintdate = 2007-07-01 }
{maintauthor = Jolle Carlestam }
{maintnotes = Optimised code. Added fail handling if language
not supported }
{maintvsrn = 1.3.1 }
{maintrelease = 1.0.0 }
{maintdate = 2007-01-30 }
{maintauthor = Jolle Carlestam }
{maintnotes = Separated into its own file
Updated code with #theDate->DayofWeek
Now uses Select }
{maintvsrn = 1.3 }
{maintrelease = 1.0.0 }
{maintdate = 2004 01 09 }
{maintauthor = Jolle Carlestam }
{maintnotes = Tag now use namespaces for on-demand loading. }
{maintvsrn = 1.2 }
{maintrelease = 1.0.0 }
{maintdate = 2002-06-01 }
{maintauthor = Jolle Carlestam }
{maintnotes = initial release }
............................................................................
Usage:
var:'thisday' = (jina_dayName: date, -language = 'se');
To change case from the language standard use -case:
var:'thisday' = (jina_dayName: date, -language = 'se', -case = 'word|sentence|lower|upper');
.............................................................................
*/
define_tag: 'dayName',
-namespace = 'jina_',
-req = 'date', -type = 'date', -copy,
-opt = 'language', -type = 'string',
-opt = 'case', -type = 'string',
-priority = 'replace',
-description = 'Outputs a given dates day 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:'DayofWeek' = #date->DayofWeek;
select: #language;
case: 'sv'; // Swedish
local: 'DaysofTheWeek' = (map: 1 = 'söndag', 2 = 'måndag', 3 = 'tisdag', 4 = 'onsdag', 5 = 'torsdag', 6 = 'fredag', 7 = 'lördag');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'de'; // German
local: 'DaysofTheWeek' = (map: 1 = 'Sonntag', 2 = 'Montag', 3 = 'Dienstag', 4 = 'Mittwoch', 5 = 'Donnerstag', 6 = 'Freitag', 7 = 'Samstag');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'fr'; // French
local: 'DaysofTheWeek' = (map: 1 = 'dimanche', 2 = 'lundi', 3 = 'mardi', 4 = 'mercredi', 5 = 'jeudi', 6 = 'vendredi', 7 = 'samedi');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'it'; // Italian
local: 'DaysofTheWeek' = (map: 1 = 'domenica', 2 = 'lunedì', 3 = 'martedì', 4 = 'mercoledì', 5 = 'giovedì', 6 = 'venerdì', 7 = 'sabato');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'es'; // Spanish
local: 'DaysofTheWeek' = (map: 1 = 'domingo', 2 = 'lunes', 3 = 'martes', 4 = 'miércoles', 5 = 'jueves', 6 = 'viernes', 7 = 'sábado');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'nl'; // Dutch
local: 'DaysofTheWeek' = (map: 1 = 'Zondag', 2 = 'Maandag', 3 = 'Dinsdag', 4 = 'Woensdag', 5 = 'Donderdag', 6 = 'Vrijdag', 7 = 'Zaterdag');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'ga'; // Irish Gaelic
local: 'DaysofTheWeek' = (map: 1 = 'Dé Domhnaigh', 2 = 'Dé Luain', 3 = 'Dé Máirt', 4 = 'Dé Céadaoin', 5 = 'Déardaoin', 6 = 'Dé hAoine', 7 = 'Dé Sathairn');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'fi'; // Finnish
local: 'DaysofTheWeek' = (map: 1 = 'sunnuntai', 2 = 'maanantai', 3 = 'tiistai', 4 = 'keskiviikko', 5 = 'torstai', 6 = 'perjantai', 7 = 'lauantai');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'no'; // Norwegian
local: 'DaysofTheWeek' = (map: 1 = 'søndag', 2 = 'mandag', 3 = 'tirsdag', 4 = 'onsdag', 5 = 'torsdag', 6 = 'fredag', 7 = 'lørdag');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'da'; // Danish
local: 'DaysofTheWeek' = (map: 1 = 'søndag', 2 = 'mandag', 3 = 'tirsdag', 4 = 'onsdag', 5 = 'torsdag', 6 = 'fredag', 7 = 'lørdag');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'pt'; // Portuguese
local: 'DaysofTheWeek' = (map: 1 = 'domingo', 2 = 'segunda feira', 3 = 'terça feira', 4 = 'quarta feira', 5 = 'quinta feira', 6 = 'sexta feira', 7 = 'sábado');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'el'; // Greek
local: 'DaysofTheWeek' = (map: 1 = '', 2 = '', 3 = '', 4 = '', 5 = '', 6 = '', 7 = '');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case: 'zh'; // Chinese
local: 'DaysofTheWeek' = (map: 1 = '', 2 = '', 3 = '', 4 = '', 5 = '', 6 = '', 7 = '');
local:'dayName' = #DaysofTheWeek->(Find: #DayofWeek);
case; // Can only be English
local:'dayName' = #date->DayofWeek: -long;
/select;
select: #case;
case: 'word'; // All words start with a capital: Tuesday | Dé Domhnaigh
#dayName -> titleCase;
case: 'sentence'; // First word start with a capital: Tuesday | Dé domhnaigh
#dayName -> lowerCase;
#dayName -> (ToTitle:1);
case: 'lower'; // All words in lower case: tuesday | dé domhnaigh
#dayName -> lowerCase;
case: 'upper'; // All words in upper case: TUESDAY | DÉ DOMHNAIGH
#dayName -> upperCase;
/select;
return:#dayName;
/define_tag;
?>
|