Data types tutorial

From Fōrmulæ wiki
Jump to: navigation, search

This page is a tutorial to manage common data types in Fōrmulæ and examples of operations you can do on them.

Data types are expressions that form the basic blocks of information in Fōrmulæ. They represent entities that you find in real world, such as numbers, strings of characters to manage pieces of text, dates to represent specific points in timeline, etc.

Numbers

Numbers and examples of operations you can perform on them are extensively discussed in the Arithmetic tutorial.

Strings

String expression represents strings, ordered sequences of single characters such as letters, digits, punctuation marks, etc.

Creation and edition

When you create a String expression (usually pressing the KeyQuote.png key), you are requested to enter it in a dialog box such the following:

String1.png

Edition of an existent string (pressing the spacebar) will show the same dialog box.

Visualization

Just like numbers, strings can be visualized in several ways.

Visualizer Description Example Empty string
"As is" The string is shown with no decorations DataTypes 02.png EmptyString AsIs.png [note 1]
Bordered The string is shown as the text it contains surrounded with a border DataTypes 03.png EmptyString Bordered.png [note 2]
Quoted The string is shown as the text inside opening and closing quotes DataTypes 04.png[note 3] EmptyString Quoted.png
  1. A special symbol is needed, otherwise the expression would be invisible and unselectable.
  2. It is a frame around a zero width rectangle.
  3. The quotes are not actually added to the text of the string, they are just a visual artifact. In the example the string remains as 7 characters long (æ is a single character).

With the "Quoted" visualizer, the quote symbols used depend on the language you are using, so this visualization is localized. See the following table:

Language Example of visualization
Albanian, Belarussian, Catalan, German (Switzerland), Greek,
Spanish, French, Italian, Norwegian, Portuguese (Portugal),
Russian, Ukrainian
«Fōrmulæ»
Bulgarian, Czech, German (Austria, Germany, Greece & Luxembourg),
Estonian, Croatian, Icelandic, Lithuanian, Macedonian,
Slovak, Slovenian, Serbian, Hungarian, Polish
„Fōrmulæ”
Finnish, Swedish ”Fōrmulæ”
Arabic ”Fōrmulæ“
Japanese, Chinese (Hong Kong & Taiwan) 「Fōrmulæ」
Hebrew ״Fōrmulæ״
Rest of the world “Fōrmulæ”

Operations

In this section, different operations on strings are shown.

A bordered visualization of string will be used.

Concatenation

Concatenation01.png

Retrieving size of a string

RetrievingSize01.png

Retrieving parts of a string

Positions in Fōrmulæ strings (and many other structures, such as lists) are 1-based, this is, the first position of a string is numbered as 1, second one is 2, etc. It is necessary to clarify it because several other programming languages are zero-based instead.

The Substring expression retrieves the sub-string of a string, from a given position to the end. Note that a space counts as a single character:

SubString01.png

The SubstringPosN expression retrieves the sub-string of a string, from a given position, taking a number of characters:

SubString02.png

The SubstringPosPos expression retrieves the sub-string of a string, from a given position, to another given position:

SubString03.png

The Split expression, splits a string as a list of their single characters:

StringSplit01.png

You can specify to split every certain number of characters. Note that the last part can have a less number of characters.

StringSplit02.png

You can provide a list of numbers. The string will be split in these positions.

StringSplit03.png

In the next example, additional positions are provided in order to split single spaces.

StringSplit04.png

You can specify a substring to act as separator. For the next example the space is used. Note that the separator itself does not appear in the list:

StringSplit05.png

But any text can be specified:

StringSplit06.png

Finding position of text

The Index retrieves the position of the FIRST occurrence of the given text:

StringIndex01.png

The Indexes retrieves a list with the positions of all the occurrences of the given text:

StringIndex02.png

Testing if a string contains a substring

The Contains expression retrieves whether a string contains another string:

StringConatins01.png

The StartsWith expression retrieves whether a string starts with another string:

StringConatins02.png

The EndsWith expression retrieves whether a string ends with another string:

StringConatins03.png

Replacing

The Replace and ReplaceAll expression replaces the first, and all occurrences respectively, of a sub-string by another string:

StringReplacing01.png

StringReplacing02.png

Changing case

The Uppercase and Lowercase changes a string to uppercase/lowercase:

StringUpperCase01.png

StringLowerCase01.png

Reversing order

The Reverse as its nombre says, reverses the order of a given string:

StringReverse01.png

Decoding/encoding to/from Unicode

Unicode is a standard for the assignment of numbers to symbols, It includes the characters from most of the writing systems characters, mathematical symbols and others, such as emojis, and it currently maps more than one million characters.

The DecodeString expression returns a list of the Unicode numbers of each character of a given String:

StringDecode01.png

Conversely, the EncodeString buils a string from a given list of Unicode numbers:

StringEncode01.png

Additional examples

Logic

Logic values

There are just two expressions on this kind:

Expression Entity that represents Visualization example [note 1]
True Truth LogicTrue.png
False Falsity LogicFalse.png
  1. The labels TRUE and FALSE can be different in your locale, depending on whether the Logic packages is already localized.

Operations

Expression Logic operation Visualization as logic symbol Mnemonic visualization [note 1] Number of operands
Left to right Right to left Left to right Right to left
Negation Negation (logic not) LogicNegationSymbol.png LogicNegationSymbolInverted.png LogicNegationMnemonic.png LogicNegationMnemonicInverted.png 1
Conjunction Conjunction (logic and) LogicConjunctionSymbol.png LogicConjunctionSymbolInverted.png LogicConjunctionMnemonic.png LogicConjunctionMnemonicInverted.png 2 or more
Disjunction Disjunction (logic or) LogicDisjunctionSymbol.png LogicDisjunctionSymbolInverted.png LogicDisjunctionMnemonic.png LogicDisjunctionMnemonicInverted.png 2 or more
Implication Implication LogicImplicationSymbol.png LogicImplicationSymbolInverted.png 2 [note 2]
Equivalence Equivalence LogicEquivalenceSymbol.png LogicEquivalenceSymbolInverted.png 2 or more
ExclusiveDisjunction Exclusive disjunction (logic xor) LogicExclusiveDisjunctionSymbol.png LogicExclusiveDisjunctionSymbolInverted.png LogicExclusiveDisjunctionMnemonic.png LogicExclusiveDisjunctionMnemonicInverted.png 2 or more
  1. The labels NOT, AND, OR and XOR can be different in your locale, depending on whether the Logic packages is already localized.
  2. It is because logical implication is not an associative operation, this is, (P → Q) → R is not equivalent to P → (Q → R).

Additional examples

Localization

Building software able to be used in several parts of the world involves two related, but different processes[1]:

  • Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. It is done usually once.
  • Localization is the process of adapting internationalized software for a specific region or language by translating text and adding locale-specific components. It is usually performed several times, one for region to be localized.

Fōrmulæ is highly internationalized software. As you have seen in previous tutorials and examples, numbers, quoted strings and other data types can be shown accordingly to your locale. It fully supports right-to-left direction.

Some expression visualizations are fully localized (it is, for every known locale), other ones are partially done. The Desktop program is also partially localized.

In this section you will know entities related to localization, such as languages, countries, locales and time zones, and how they can be used to format numbers, currencies, to quote strings and to get name of numbers according to a certain locale.

Languages

A Language expression represents a human language. Internally it is stored as a 2-character lowercase language code, according to the ISO 639-1 standard. For example the code for the English language is "en".

It is visualized as its name, in the following way (it resembles a label):

EnglishEnglishVisualization.png

It is shown so in order to differentiate it from the String "English", which is another, different expression.

The name shown is fully localized. if your operating system had been installed in German, the expression for the English language would look as:

EnglishGermanVisualization.png

To select a language, choose the "Language" editor from the list in the left part of the Desktop. The following windows will be shown:

LanguageSelection.png

The getLanguageList expression retrieves a list of known languages:

GetLanguageList.png

Countries

A Country expression represents a country. Internally it is stored as a 2-character uppercase country code, according to the ISO 3166-1 standard, for example the code for United States is "US".

It is visualized as its name, in the following way:

USEnglishVisualization.png

Again, the name shown is fully localized. if your operating system had been installed in German, the expression for the Unites States would look as:

USGermanVisualization.png

To select a country, choose the "Country" editor from the list in the left part of the Desktop. The following windows will be shown:

CountrySelection.png

The GetCountryList expression retrieves a list of known countries:

GetCountryList.png

Locales

A Locale expression represents a locale, a geographic region that defines a language (or variation of a language) and set of representation forms of numbers, dates, currencies, etc.

Locales are shown as a combination of language and country, in the form language (country)".

A locale is visualized same way as languages and countries:

En USVisualization.png

To select a locale, choose the "Locale" editor from the list in the left part of the Desktop. The following windows will be shown:

LocaleSelection.png

The GetLocaleList expression retrieves a list of known locales:

GetLocaleList.png

Time zones

A map of time zones. Click/tap to enlarge

A TimeZone expression represents a time zone, a region of the globe that observes a uniform standard time for legal, commercial, and social purposes. Time zones tend to follow the boundaries of countries and their subdivisions because it is convenient for areas in close commercial or other communication to keep the same time.

Time zones on land are offset from coordinated universal time (UTC) by a specific amount of time, typically a whole number of hours, but there are cases of offsets containing fractional parts of an hour.

Many time zones observe daylight saving time for part of the year, typically by adjusting local clock time by an hour.

Time zone expressions are shown as languages and countries, the text shown is according to following:

Type of time zone Format Notes Example
It does not observe daylight saving time (UTC +/-XX:XX) Zone/City XX.XX is the offset from UTC TimeZonePanamaVisualization.png
It observes daylight saving time (UTC +/-XX:XX +/-YY:YY) Zone/City XX.XX is the offset from UTC in standard time
YY.YY is the offset from UTC in daylight saving time
TimeZoneParisVisualization.png

To select a time zone, choose the "Time Zone" editor from the list in the left part of the Desktop. The following window will be shown:

TimeZoneSelection.png

The GetTimeZoneList expression retrieves a list of known time zones:

GetTimeZoneList1.png

Formatting

The fact that Fōrmulæ can show the expressions for languages, countries, locales and time zones in your own language is cool, but it could be even cooler if you could get the names of these entities in locales other than yours (given that they are localized).

Localized formatting is the action of retrieving the information of (localized) entities (such as languages, countries, locales, time zones, etc.) according to a given locale. The result is usually provided as Strings.

Languages names

The LanguageName expression retrieves the name of a given language, in the current locale (United States, in this example):

GetLanguageName01.png

Please note that the result is a String.

You can provide a Locale expression as the second argument.

Example: How is the German language said in German ?

GetLanguageName02.png

How is German language said in Mexican Spanish ?

GetLanguageName03.png

How is French language said in Russian ?

GetLanguageName04.png

Country names

Similarily, the expression CountryName retrieves the name of a country, in the current or given locale:

How is Greece said in Danish ?

GetCountryName01.png

How is Portugal said in Japanese ?

GetCountryName02.png

Quoting strings

For this exercise, we will assume that we are using the visualization of strings inside a box, so the string "Fōrmulæ" would be shown as:

BoxedString.png

The QuoteString expression, adds quotes the the given string, according to the current or given locale:

Let us get the string "Fōrmulæ" as is were quoted in Italian:

QuoteString01.png

Note that the new string is 2 character longer, because it effectively adds the quotes to the original string.

Let us get the string "Fōrmulæ" as is were quoted in Hungarian:

QuoteString02.png

Formatting numbers

As (quoted) strings, languages, countries and other localized entities, numbers are usually shown accordingly to the current locale, but is is also possible to format them for any other locale.

The FormatNumber expression, format a number according to the current or given locale:

FormatNumber01.png

FormatNumber02.png

Formatting currencies

The FormatCurrency expression, format a number as currency according to the current or given locale:

FormatCurrency01.png

Number names

The NumberName expression, provides the name of a number, according to the current or given locale:

NumberName01.png

NumberName02.png

What is the name of the number 1 followed by 150 zeroes ?

NumberName03.png

The greatest number supported is 10303-1, this is the number formed by 303 nines, and its name is:

"nine hundred ninety-nine novennonagintillion nine hundred ninety-nine octononagintillion nine hundred ninety-nine septennonagintillion nine hundred ninety-nine sesnonagintillion nine hundred ninety-nine quinquanonagintillion nine hundred ninety-nine quattuornonagintillion nine hundred ninety-nine tresnonagintillion nine hundred ninety-nine duononagintillion nine hundred ninety-nine unononagintillion nine hundred ninety-nine nonagintillion nine hundred ninety-nine novenoctogintillion nine hundred ninety-nine octooctogintillion nine hundred ninety-nine septenoctogintillion nine hundred ninety-nine sesoctogintillion nine hundred ninety-nine quinquaoctogintillion nine hundred ninety-nine quattuoroctogintillion nine hundred ninety-nine tresoctogintillion nine hundred ninety-nine duooctogintillion nine hundred ninety-nine unoctogintillion nine hundred ninety-nine octogintillion nine hundred ninety-nine novenseptuagintillion nine hundred ninety-nine octoseptuagintillion nine hundred ninety-nine septenseptuagintillion nine hundred ninety-nine sesseptuagintillion nine hundred ninety-nine quinquaseptuagintillion nine hundred ninety-nine quattuorseptuagintillion nine hundred ninety-nine tresseptuagintillion nine hundred ninety-nine duoseptuagintillion nine hundred ninety-nine unseptuagintillion nine hundred ninety-nine septuagintillion nine hundred ninety-nine novensexagintillion nine hundred ninety-nine octosexagintillion nine hundred ninety-nine septensexagintillion nine hundred ninety-nine sessexagintillion nine hundred ninety-nine quinquasexagintillion nine hundred ninety-nine quattuorsexagintillion nine hundred ninety-nine tressexagintillion nine hundred ninety-nine duosexagintillion nine hundred ninety-nine unsexagintillion nine hundred ninety-nine sexagintillion nine hundred ninety-nine novenquinquagintillion nine hundred ninety-nine octoquinquagintillion nine hundred ninety-nine septenquinquagintillion nine hundred ninety-nine sesquinquagintillion nine hundred ninety-nine quinquaquinquagintillion nine hundred ninety-nine quattuorquinquagintillion nine hundred ninety-nine tresquinquagintillion nine hundred ninety-nine duoquinquagintillion nine hundred ninety-nine unquinquagintillion nine hundred ninety-nine quinquagintillion nine hundred ninety-nine novenquadragintillion nine hundred ninety-nine octoquadragintillion nine hundred ninety-nine septenquadragintillion nine hundred ninety-nine sesquadragintillion nine hundred ninety-nine quinquaquadragintillion nine hundred ninety-nine quattuorquadragintillion nine hundred ninety-nine tresquadragintillion nine hundred ninety-nine duoquadragintillion nine hundred ninety-nine unquadragintillion nine hundred ninety-nine quadragintillion nine hundred ninety-nine noventrigintillion nine hundred ninety-nine octotrigintillion nine hundred ninety-nine septentrigintillion nine hundred ninety-nine sestrigintillion nine hundred ninety-nine quinquatrigintillion nine hundred ninety-nine quattuortrigintillion nine hundred ninety-nine trestrigintillion nine hundred ninety-nine duotrigintillion nine hundred ninety-nine untrigintillion nine hundred ninety-nine trigintillion nine hundred ninety-nine novemvigintillion nine hundred ninety-nine octovigintillion nine hundred ninety-nine septemvigintillion nine hundred ninety-nine sesvigintillion nine hundred ninety-nine quinquavigintillion nine hundred ninety-nine quattuorvigintillion nine hundred ninety-nine tresvigintillion nine hundred ninety-nine duovigintillion nine hundred ninety-nine unvigintillion nine hundred ninety-nine vigintillion nine hundred ninety-nine novendecillion nine hundred ninety-nine octodecillion nine hundred ninety-nine septendecillion nine hundred ninety-nine sedecillion nine hundred ninety-nine quinquadecillion nine hundred ninety-nine quattuordecillion nine hundred ninety-nine tredecillion nine hundred ninety-nine duodecillion nine hundred ninety-nine undecillion nine hundred ninety-nine decillion nine hundred ninety-nine nonillion nine hundred ninety-nine octillion nine hundred ninety-nine septillion nine hundred ninety-nine sextillion nine hundred ninety-nine quintillion nine hundred ninety-nine quadrillion nine hundred ninety-nine trillion nine hundred ninety-nine billion nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine"

Time

The Time expression represents a single point in the timeline. It has a precision of milliseconds. It is neither associated with any timezone nor any calendar.

The most common visualization of Time expressions in based in the Gregorian Calendar. It shows the time it represents in the default time zone, which is the time zone defined in the computer you are running Fōrmulæ.

There can be visualizations based in other calendars, but we will use in this tutorial the default one, because is the most used in the world.

Creation of time expressions

As an example, at the moment of writing this article, the last equinox was in March 20 of 2019, at 9:58 PM, Universal time (UTC).

This point of time can be introduced as:

TimeEdition.png

Visualization of time expressions

Visualization is referred to the time zone of your computer. It is also fully localized, in other words, it is shown with the format of your locale.

In Los Angeles, the time we recently created would be visualized as:

TimeVisualization01.png

However, this same time would be shown in Paris as

TimeVisualization02.png

Note that they do not shown the same hour, because the difference of their time offsets.

About (BC) time

If a Time expression refers to a time in the BC era (before Christ), the text (BC) will be prepended in its text.

TimeVisualizationBC01.png

About daylight saving time

There is an ambiguity for time zones that observe daylight saving time. For example, in 2019 on the time zone associated with Los Angeles, the daylight saving time starts at March 10, 2:00 AM, so the next minute after 1:59 AM is 3:00 AM instead of 2:00 AM. There is a 1-hour gap between 2:00 AM and 3:00 AM. Before 2:00 AM is standard time, and at and after 3:00 AM is daylight saving time. Conversely, the daylight saving time ends in November 3 at 2:00 AM, so the next minute after 1:59 AM is 1:00 AM instead of 2:00 AM. There is a 1-hour overlap between 1:00 AM and 2:00 AM. The first one occurs (chronologically) in daylight saving time while the second one is in standard time. See the following chart (the horizontal axis is time, from the start to the end of 2019. It is not in scale):

LosAngeles2019.png

This ambiguity happens very rarely (an hour of the whole year). If a time is in this overlap, the visualization shows if it refers to a standard time or a daylight saving time.

For example, the time 1:30 AM of such that gap will be shown as TimeOverlap01.png if it is in the daylight saving time, and as TimeOverlap02.png otherwise (in standard time).

Retrieving time components

You can get specific values of a given time, such as the era, year, month, day of the month, hour (in 12 or 24 hour format), minutes, seconds or milliseconds:

DataTypes Time01.png

The following is the complete list:

Expression First parameter
expression
Second parameter
expression (optional)
What it returns Returned values
GetEra Time TimeZone The era (before Christ or anno Domini) of the given time, in the current or given time zone Time BC.png or Time AD.png
GetYear The year of the given time, in the current or given time zone A Number expression, always greater than 0 [note 1]
GetMonth The month of the given time, in the current or given time zone Time January.png, Time February.png, Time March.png, Time April.png, Time May.png, Time June.png, Time July.png,
Time August.png, Time September.png, Time October.png, Time November.png, Time December.png
GetDayOfMonth The day of month of the given time, in the current or given time zone A Number expression, between 1 and 31
GetDayOfYear The day of year of the given time, in the current or given time zone A Number expression, between 1 and 366
GetWeekDay The week day of the given time, in the current or given time zone Time Sunday.png, Time Monday.png, Time Tuesday.png, Time Wednesday.png,
Time Thursday.png, Time Friday.png, Time Saturday.png
GetHour12 The hour of the given time, in 12-hour format, in the current or given time zone A Number expression, between 1 and 12
GetMeridiem The meridiem (ante meridiem, before midday) or (post meridiem, past midday)
of the given time, in the current or given time zone
Time AM.png, Time PM.png
GetHour24 The hour of the given time, in 24-hour format, in the current or given time zone A Number expression, between 0 and 23
Getminute The minute of the given time, in the current or given time zone A Number expression, between 0 and 59
GetSecond The second of the given time, in the current or given time zone A Number expression, between 0 and 59
GetMillisecond The millisecond of the given time, in the current or given time zone A Number expression, between 0 and 999
InDaylightSving Whether the given time is in daylight saving or not, in the current or given time zone LogicTrue.png or LogicFalse.png [note 2]
GetWeekOfYear The number of week of the the given time, in the current or given time zone A Number expression, between 1 and 52
GetFirstDayOfWeek Locale The first day of the week of the the given time, in the current or given locale Time Sunday.png, Time Monday.png or Time Saturday.png
  1. There was no year zero in the Gregorian calendar.
  2. If the current or given locale does not observe daylight saving time, LogicFalse.png is always returned.

The GeValues expression retrieves the components that uniquely defines the current or given time. The result is a list of 9 elements containing the following expressions:

# Element Description
1 The era
2 The year
3 The month
4 The day of the month
5 The hour of the day (in 24-hour format)
6 The minutes
7 The seconds
8 The milliseconds
9 Whether the time is in daylight saving or not

As an example, for the equinox we already created is (the current time zone is Los Angeles):

DataTypes Time02.png

To show that the value of the hour is correct, note that the Los Angeles time zone is TimeZoneLosAngeles.png. As the result says, that such time is in daylight saving time (it started March 10). The hour of the equinox was 21:58 (UTC). Then 21:58 (UTC) - 07:00 (offset in daylight saving time) = 14:58 (local time).

To know the time components of the same time, but in the time zone associated to Paris:

DataTypes Time03.png

To show that the value of the hour is correct, note that as the result says, such that time was in standard time (in Paris time zone, the daylight saving time is from March 31 to October 27, in 2019). The hour of the equinox was 21:58 (UTC). Then 21:58 (UTC) + 01:00 (offset in standard time) = 22:58 (local time).

Names of time components

The expressions GetMonthName and GetWeekDayName are fully localized, and they retrieve a string containing the name of the month and day of week, respectively for the current or given locale:

DataTypes Time04.png

Creation of time expressions

A Time expression can be build from time components.

The CreateTime expression retrieves a Time given the following time components:

# Parameter Description Valid expressions
1 The era Time BC.png or Time AD.png
2 The number of year A Number expression, always greater than 0
3 The month Time January.png, Time February.png, Time March.png, Time April.png, Time May.png, Time June.png, Time July.png,
Time August.png, Time September.png, Time October.png, Time November.png, Time December.png
4 The number of the day of the month A Number expression, between 1 and 31[note 1]
5 The number of the hour, in 24-hour format A Number expression, between 0 and 23
6 The number of minutes A Number expression, between 0 and 59
7 The number of seconds A Number expression, between 0 and 59
8 The number of milliseconds A Number expression, between 0 and 999
9 Whether the time is in daylight saving or not LogicTrue.png, LogicFalse.png[note 2]
10 (optional) The time zone A TimeZone expression
  1. Several months, or combinations of year/month will accept up to 28, 29 o 30 days.
  2. This value is used only if the time created with the other parameters produces an ambiguous time (it is, into the daylight-saving/standard time overlap). If it is not the case, this value is completely ignored and it can even be the Null expression.

The equinox time of previous examples can be created by:

CreateTime01.png

Time offset

The OffsetTime expression is useful if you want to add or subtract units of time for one or several time components, from a given Time expression.

It takes the following parameters:

# Parameter Description Valid expressions
1 The time of reference A Time expression
2 Number of years to add/subtract Any integer number
It can be negative, zero or positive
3 Number of months to add/subtract
4 Number of days to add/subtract
5 Number of hours to add/subtract
6 Number of minutes to add/subtract
7 Number of seconds to add/subtract
8 Number of milliseconds to add/subtract

Examples:

To show that there was no year zero, the last millisecond of the year 1BC was (BC) December 31, at 23:59:59:999. Adding a single millisecond to it we will get:

OffsetTime 01.png

According to the history, in October 1582, the day that followed 4th was 15th:

OffsetTime 02.png

The following rules apply for the offset of times:

  • There are time components more general than others. The most general is the year, the less general is the millisecond.
  • The order of application is from more general to less general, so the number of years to add or subtract is applied first (if it is different than 0), then the number of months (if it is different than 0), and so on.
  • Every time a specification is applied to a component, the time is rolled in that component, possibly affecting more general components, but no less general components. For example if the initial time is 2020 August 23, 12:34:56:555 and it is specified to add 5 months, it will become 2021 January 23, 12:34:56:555
  • Sometimes, specially with years and months, that the last operation would produce invalid times. For example if the initial time rests in March 31 and you tried to add a single month. It is not possible to get April 31. In these special case, the immediate less general component is subtracted as many units as necessary to get a valid time. For this example, the immediate less general component is days and it is necessary to subtract a single day to get a valid time April 30.
  • It seems like it does not happen with hours, minutes and seconds, but it is false! Let us see a counterexample. Suppose that your are in Los Angeles and your initial time is 2019, November 10 at 01:30 AM (it is, a half hour before the time overlap). If you add 3 hours you will effectively get 04:30 AM, but the difference between the two times is not 3 hours, it is actually 4 hours.

If you are working with absolute intervals of time (not related with any calendar, for example, as the duration of a scientific experiment), the best options is to convert such that time to milliseconds.

Time comparison

A Time expression can be compared against another one, by the using of the Equals, Different, Greater, GreaterOrEquals, Less, LessOrEquals or Compare expressions:

A Time expression is less than other, if it occurred BEFORE:

TimeComparison02.png

Which event occurs first, the tea in London, or noon in New York?

TimeComparison01.png

Time formatting

Time expressions can be formatted to get a string with the formatted time according to certain locale, time zone or both.

The are 3 type of formats, short, medium and long. The corresponding expressions are FormaTimeShort, FormaTimeMedium and FormaTimeLong.

They accepts a time to format as the first parameter. If no additional parameters are provided, it used the current locale and time zone:

TimeFormat.png

A Locale expression can be used as a second parameter:

TimeFormatLocale.png

A TimeZone expression can be used as a second parameter:

TimeFormatTimeZone.png

You can provide both a Locale and a TimeZone as additional parameters. Note that they can be specified in any order (but the time must be first):

TimeFormatBoth.png

Additional examples

Colors

A Color expression represents a color in real world.

To create a Color expression, select the editor from the left section of the Desktop. The following dialog will be shown:

ColorEdition01.png

A Color expression is used by many other expressions, but by itself, it is shown as a single box in the color it represents:

ColorVisualization01.png

A Color expression can be created by the CreateColor expression. It takes the following three parameters, that are the components of color in the RGB color model:

# Parameter Description Valid expressions
1 Component of red A numeric expression, from 0 to 1
2 Component of green
3 Component of blue

Example: To create a list with the colors red, green and blue. They are called additive colors because they are added together from black to create a color. The sum of these components creates white. It is the model used to create light from black media, such a screen.

CreateColor01.png

The CMYK color model is called subtractive because inks "subtract" the colors red, green and blue from white light. White light minus red leaves cyan, white light minus green leaves magenta, and white light minus blue leaves yellow. It is the model to create light from white media, for example for printing in white paper.

To create a list with the colors cyan, magenta and yellow:

CreateColor02.png

To show that the sum of no components (0) creates black, and the sum of full components (1) creates white. Intermediate values (with same value for the three components) creates shades of gray:

CreateColor03.png

Additional examples

References

  1. Internationalization and localization, from Wikipedia