[date_int]

Description

Link: [date_int]
Author: Johan Sölve
Category: Date
Version: 8.x
License: Public Domain
Posted: Dec. 15, 2008
Updated: Dec. 16, 2008
More by this author...

[date_int] is a custom type that works just like the native [date] type but that supports international output of monthnames and daynames.

The [date_int->format] member tag accepts a new -language parameter where you specify a 2-character language code for the desired language.
Falls back to English when specifying an unsupported language.

[date_int->format] also accepts a -case parameter to control the character case of the output. -case can be word, sentence, lower or upper.
Defaults to whatever case that is specified for the daynames and monthnames for each language.

[date_int->format] also accepts a -length parameter that specifies the number of characters that will be used for the abbreviated dayname and monthname (%a and %b).
Defaults to 3.

[date_int->dayofweek] and [date_int->month] supports the -language parameter as well as the -length parameter.

A new member tag [date_int -> setlanguage] makes it possible to set a default language for the [date_int] instance, which lets [date_int -> setformat] produce localized output.

Limitations:
date_int(-format='format string') only supports parsing English daynames and monthnames.

Update 2008-12-16:

  • optimizations
  • added the -length parameter
  • added member tag ->setlanguage to set default language for the instance
  • added support for ->dayofweek, ->month and ->setformat
  • uploaded the tag as zip file instead, to make Chinese and Greek survive


Credits to Jolle Carlestam who wrote the international monthName and dayName tags, which this custom type is based on.

Parameters

-formatstring string, required Standard Lasso date format string
-language string, optional Two-character language code for the desired output. Defaults to 'en' if the specified language is not supported.
-case string, optional The desired character case for the output. Specify 'word', 'sentence', 'lower' or 'upper'.
-length integer, optional Specifies the number of characters to use for the abbreviated dayname and monthname. Defaults to 3.

Sample Usage

date_int -> format('%A %d %B', -language='sv', -case='sentence');  // Måndag 15 december
date_int -> dayofweek(-long, -language='pt'); // terça feira
var('d'=date_int);
$d -> setlanguage('sv');
$d -> dayofweek(-long);  // måndag
$d -> setformat('%A');
$d;   // måndag
						

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.

date_int.inc.zip (3.43 kb)

 

Related Tags



Comments

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net