Difference between revisions of "Data types tutorial"
(→Time) 
(→Time) 

Line 261:  Line 261:  
[[File:DataTypes_Time01.pngborder]]  [[File:DataTypes_Time01.pngborder]]  
+  
+  { class="wikitable" style="textalign: center;"  
+  ! Expression  First parameter<br>expression  Second parameter<br> expression (optional)  What it returns  Return values  
+    
+   <code>GetEra</code>  <code>Time</code>  <code>TimeZone</code>  The era of the given time, in the current or given time zone  Ac or DC  
+    
+   <code>GetYear</code>  <code>Time</code>  <code>TimeZone</code>  The year of the given time, in the current or given time zone  A <code>Number</code> expression, always greater than 0  
+    
+   <code>GetMonth</code>  <code>Time</code>  <code>TimeZone</code>  The month of the given time, in the current or given time zone  xxx  
+    
+   <code>GetDayOfMonth</code>  <code>Time</code>  <code>TimeZone</code>  The day of month of the given time, in the current or given time zone  A <code>Number</code> expression, between 1 and 31  
+    
+   <code>GetDayOfYear</code>  <code>Time</code>  <code>TimeZone</code>  The day of year of the given time, in the current or given time zone  A <code>Number</code> expression, between 1 and 365  
+    
+   <code>GetWeekDay</code>  <code>Time</code>  <code>TimeZone</code>  The week day of the given time, in the current or given time zone  xxx  
+    
+   <code>GetHour12</code>  <code>Time</code>  <code>TimeZone</code>  The hour of the given time, in 12 hour format, in the current or given time zone  A <code>Number</code> expression, between 1 and 12  
+    
+   <code>GetMeridiem</code>  <code>Time</code>  <code>TimeZone</code>  The meridiem of the given time, in the current or given time zone  xxx  
+    
+   <code>GetHour24</code>  <code>Time</code>  <code>TimeZone</code>  The hour of the given time, in 24 hour format, in the current or given time zone  A <code>Number</code> expression, between 0 and 23  
+    
+   <code>GetMinute</code>  <code>Time</code>  <code>TimeZone</code>  The minute of the given time, in the current or given time zone  A <code>Number</code> expression, between 0 and 59  
+    
+   <code>GetSecond</code>  <code>Time</code>  <code>TimeZone</code>  The second of the given time, in the current or given time zone  A <code>Number</code> expression, between 0 and 59  
+    
+   <code>GetMilliSecond</code>  <code>Time</code>  <code>TimeZone</code>  The millisecond of the given time, in the current or given time zone  A <code>Number</code> expression, between 0 and 999  
+    
+   <code>InDayLightSaving</code>  <code>Time</code>  <code>TimeZone</code>  If the given time is in daylight saving, in the current or given time zone  xxx  
+    
+   <code>GetWeekOfYear</code>  <code>Time</code>  <code>TimeZone</code>  The number of week of the the given time, in the current or given time zone  A <code>Number</code> expression, between 1 and 53  
+    
+   <code>GetFirstDayOfWeek</code>  <code>Time</code>  <code>Locale</code>  The first day of the week of the the given time, in the current or given locale  Usually x, y and z  
+  }  
The <code>GetValues</code> retrieves the most important values in a single call:  The <code>GetValues</code> retrieves the most important values in a single call: 
Revision as of 19:44, 12 July 2019
This page is under construction
This page is a tutorial to manage common data types in Fōrmulæ and examples of operations you can do on them.
Simple data structures are expressions that act as containers of information 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
Text strings are ordered sequences of single characters such as letters, digits, punctuation marks, etc.
Alternate definitions of simple data structures state that they can only contain indivisible pieces of information, in such that case strings are not simple data types, but in the real world they are more commonly used as a unity.
Edition
When you select an edition to create a String (usually pressing the key), you are requested to enter it in a dialog box such the following:
Visualization
Just like numbers, strings can be visualized in several ways:
As is
With this visualizer, the string is shown as the text it contains, with no extra decorations:
Bordered
The previous visualizer has the disadvantage that ti could confuse the user about which characters form the string, specially if it contains spaces. Notice that such that confusion is visual, there is no possibility of ambiguity because Fōrmulæ is a structural editor, no a text editor.
With this visualizer, the string is shown as the text it contains surrounded with a border
Quoted
With this visualizer, the string is shown as the text inside opening and closing quotes. The quote symbols used depend on the language you are using, so this visualization is Language dependent. See the following table:
Language  Example of visualization 

Belarussian, Catalan, German (Switzerland), Greek, Spanish, French, Italian, Norwegian, Portuguese (Portugal), Russian, Albanian, 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æ” 
Logic
There are just two expression on this kind:
Entity that represents  Tag  Visualization example 

Truth  Logic.True 

Falsity  Logic.False 
Localization
Fōrmulæ is highly localizable software.
Languages
A Localization.Language.Language
expression represents a human language. Internally it is stored as a 2character lowercase language code, according to the ISO 6391 standard. For example the code for the English language is "en". It is visualized as its name, in the following way:
It is shown so in order to differentiate it from the String "English", which is another, different expression.
The name shown is, in fact locale dependent. if your operating system had been installed in German, the expression for the English language would look as:
Countries
A Localization.Country.Country
expression represents a country. Internally it is stored as a 2character uppercase country code, according to the ISO 31661 standard. For example the code for United States is "US". It is visualized as its name, in the following way:
Again, the name shown is locale dependent. if your operating system had been installed in German, the expression for the Unites States would look as:
Locales
A locale is 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)" and it is visualized same way as languages and countries:
Time zones
A time zone is 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.
Most of the 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.
Some time zone countries use daylight saving time for part of the year, typically by adjusting local clock time by an hour.
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 your (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 GetLanguageName
expression retrieves the name of a given language, in the current locale (United States, in this example):
Please note that the result is a String.
You can provide a Locale
expression as the second argument.
How is the German language said in German ?
How is German language said in Mexican Spanish ?
How is French language said in Russian ?
Country names
Similarily, the expression GetCountryName
retrieves the name of a country, in the current or given locale:
How is Greece said in Danish ?
How is Portugal said in Japanese ?
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:
The QuoteString
expression, add 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:
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:
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.
Formatting currencies
Number names
What is the name of the number 1 followed by 150 zeroes ?
The greatest number supported is 10^{303}1, this is the number formed by 303 nines, and its name is:
"nine hundred ninetynine novennonagintillion nine hundred ninetynine octononagintillion nine hundred ninetynine septennonagintillion nine hundred ninetynine sesnonagintillion nine hundred ninetynine quinquanonagintillion nine hundred ninetynine quattuornonagintillion nine hundred ninetynine tresnonagintillion nine hundred ninetynine duononagintillion nine hundred ninetynine unononagintillion nine hundred ninetynine nonagintillion nine hundred ninetynine novenoctogintillion nine hundred ninetynine octooctogintillion nine hundred ninetynine septenoctogintillion nine hundred ninetynine sesoctogintillion nine hundred ninetynine quinquaoctogintillion nine hundred ninetynine quattuoroctogintillion nine hundred ninetynine tresoctogintillion nine hundred ninetynine duooctogintillion nine hundred ninetynine unoctogintillion nine hundred ninetynine octogintillion nine hundred ninetynine novenseptuagintillion nine hundred ninetynine octoseptuagintillion nine hundred ninetynine septenseptuagintillion nine hundred ninetynine sesseptuagintillion nine hundred ninetynine quinquaseptuagintillion nine hundred ninetynine quattuorseptuagintillion nine hundred ninetynine tresseptuagintillion nine hundred ninetynine duoseptuagintillion nine hundred ninetynine unseptuagintillion nine hundred ninetynine septuagintillion nine hundred ninetynine novensexagintillion nine hundred ninetynine octosexagintillion nine hundred ninetynine septensexagintillion nine hundred ninetynine sessexagintillion nine hundred ninetynine quinquasexagintillion nine hundred ninetynine quattuorsexagintillion nine hundred ninetynine tressexagintillion nine hundred ninetynine duosexagintillion nine hundred ninetynine unsexagintillion nine hundred ninetynine sexagintillion nine hundred ninetynine novenquinquagintillion nine hundred ninetynine octoquinquagintillion nine hundred ninetynine septenquinquagintillion nine hundred ninetynine sesquinquagintillion nine hundred ninetynine quinquaquinquagintillion nine hundred ninetynine quattuorquinquagintillion nine hundred ninetynine tresquinquagintillion nine hundred ninetynine duoquinquagintillion nine hundred ninetynine unquinquagintillion nine hundred ninetynine quinquagintillion nine hundred ninetynine novenquadragintillion nine hundred ninetynine octoquadragintillion nine hundred ninetynine septenquadragintillion nine hundred ninetynine sesquadragintillion nine hundred ninetynine quinquaquadragintillion nine hundred ninetynine quattuorquadragintillion nine hundred ninetynine tresquadragintillion nine hundred ninetynine duoquadragintillion nine hundred ninetynine unquadragintillion nine hundred ninetynine quadragintillion nine hundred ninetynine noventrigintillion nine hundred ninetynine octotrigintillion nine hundred ninetynine septentrigintillion nine hundred ninetynine sestrigintillion nine hundred ninetynine quinquatrigintillion nine hundred ninetynine quattuortrigintillion nine hundred ninetynine trestrigintillion nine hundred ninetynine duotrigintillion nine hundred ninetynine untrigintillion nine hundred ninetynine trigintillion nine hundred ninetynine novemvigintillion nine hundred ninetynine octovigintillion nine hundred ninetynine septemvigintillion nine hundred ninetynine sesvigintillion nine hundred ninetynine quinquavigintillion nine hundred ninetynine quattuorvigintillion nine hundred ninetynine tresvigintillion nine hundred ninetynine duovigintillion nine hundred ninetynine unvigintillion nine hundred ninetynine vigintillion nine hundred ninetynine novendecillion nine hundred ninetynine octodecillion nine hundred ninetynine septendecillion nine hundred ninetynine sedecillion nine hundred ninetynine quinquadecillion nine hundred ninetynine quattuordecillion nine hundred ninetynine tredecillion nine hundred ninetynine duodecillion nine hundred ninetynine undecillion nine hundred ninetynine decillion nine hundred ninetynine nonillion nine hundred ninetynine octillion nine hundred ninetynine septillion nine hundred ninetynine sextillion nine hundred ninetynine quintillion nine hundred ninetynine quadrillion nine hundred ninetynine trillion nine hundred ninetynine billion nine hundred ninetynine million nine hundred ninetynine thousand nine hundred ninetynine" 
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.
Example. At the moment of writing this article, the last equinox was in March 20 of 2019, at 21:58 Universal time (this is, in Greenwich time).
This point of time can be introduced as:
In Los Angeles, this time would be visualized as:
However, this same time would be shown in Paris as:
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:
Expression  First parameter expression 
Second parameter expression (optional) 
What it returns  Return values 

GetEra 
Time 
TimeZone 
The era of the given time, in the current or given time zone  Ac or DC 
GetYear 
Time 
TimeZone 
The year of the given time, in the current or given time zone  A Number expression, always greater than 0

GetMonth 
Time 
TimeZone 
The month of the given time, in the current or given time zone  xxx 
GetDayOfMonth 
Time 
TimeZone 
The day of month of the given time, in the current or given time zone  A Number expression, between 1 and 31

GetDayOfYear 
Time 
TimeZone 
The day of year of the given time, in the current or given time zone  A Number expression, between 1 and 365

GetWeekDay 
Time 
TimeZone 
The week day of the given time, in the current or given time zone  xxx 
GetHour12 
Time 
TimeZone 
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 
Time 
TimeZone 
The meridiem of the given time, in the current or given time zone  xxx 
GetHour24 
Time 
TimeZone 
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 
Time 
TimeZone 
The minute of the given time, in the current or given time zone  A Number expression, between 0 and 59

GetSecond 
Time 
TimeZone 
The second of the given time, in the current or given time zone  A Number expression, between 0 and 59

GetMilliSecond 
Time 
TimeZone 
The millisecond of the given time, in the current or given time zone  A Number expression, between 0 and 999

InDayLightSaving 
Time 
TimeZone 
If the given time is in daylight saving, in the current or given time zone  xxx 
GetWeekOfYear 
Time 
TimeZone 
The number of week of the the given time, in the current or given time zone  A Number expression, between 1 and 53

GetFirstDayOfWeek 
Time 
Locale 
The first day of the week of the the given time, in the current or given locale  Usually x, y and z 
The GetValues
retrieves the most important values in a single call: