SigServer:SignatureMath: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
 
(5 intermediate revisions by 3 users not shown)
Line 30: Line 30:
  "1"
  "1"
This is too a number, because a check is performed on every string to see whether it is a number or not.
This is too a number, because a check is performed on every string to see whether it is a number or not.
  "-1"
  -1
This is the most efficient way to specify a negative number. Because of the way the parsing algoritm works only writing <code>-1</code> doesn't work.
This is a negative number. As of version 1.1.0, they are now supported without hacks.


'''Example: Strings'''
'''Example: Strings'''
Line 42: Line 42:
  true
  true
  false
  false
Boolean values may only be lowercase.
Boolean values may only be lower case.


=== Operators ===
=== Operators ===
SigMath supports some basic operators. Arithmetic operators have the highest priority. Comparison operators have the second highest priority. Logic operators have the least priority. Parenthesis may be used to group expressions, such as (1 + 2) * 3 = 9.
SigMath supports some basic operators. Arithmetic operators have the highest priority. Comparison operators have the second highest priority. Logic operators have the least priority. Brackets may be used to group expressions, such as (1 + 2) * 3 = 9.


==== Arithmetic Operators ====
==== Arithmetic Operators ====
Line 76: Line 76:
;&&
;&&
:Checks if the first argument and the second argument are true. If so ''true'' is returned.
:Checks if the first argument and the second argument are true. If so ''true'' is returned.
;!
:Returns the opposite of the immediately following boolean value.


=== Variables ===
=== Variables ===
Line 196: Line 198:


==== date ====
==== date ====
  ''string'' '''date'''(''string'' format[, ''string'' time])
  ''string'' '''date'''(''string'' format[, ''string'' time[, ''number'' offset]])
Returns date and time according to the first argument. The format syntax is the same as PHP's date(). The optional argument may be a timestamp or string with date.
''string'' '''date'''(''string'' format[, ''number'' timestamp[, ''number'' offset]])
''string'' '''date'''(''string'' format, "now"[, ''number'' offset])
Returns the date and time in the format specified by the first argument. The format syntax is the same as [https://secure.php.net/manual/en/function.date.php PHP's date()]. The first optional argument may be either:
 
* a string with date
* a Unix timestamp
* the string "now", in the case you want to use the third argument with the current timestamp
 
The second optional argument specifies the number of seconds to add or subtract from the specified time. This is useful if you want to shift all dates in your signature to a different timezone than the server is running on.


Example:
Example:
Line 203: Line 213:
  <nowiki>{{ date("H:i:s") }}                        <!-- Returns current time, e.g. "19:50:37" --></nowiki>
  <nowiki>{{ date("H:i:s") }}                        <!-- Returns current time, e.g. "19:50:37" --></nowiki>
  <nowiki>{{ date("Y-m-d", "1995-10-03T20:30:37") }} <!-- Returns date "1995-10-03" --></nowiki>
  <nowiki>{{ date("Y-m-d", "1995-10-03T20:30:37") }} <!-- Returns date "1995-10-03" --></nowiki>
<nowiki>{{ date("Y-m-d H:i:s", "1995-10-03T20:30:37", -7200) }} <!-- Returns "1995-10-03 18:30:37" --></nowiki>


==== fetchvar ====
==== fetchvar ====
Line 215: Line 226:
  <nowiki>{{ @test2 = 1 }}</nowiki>
  <nowiki>{{ @test2 = 1 }}</nowiki>
  <nowiki>{{ fetchvar("$latestwatched_id" + @test2 + "_aname") }} <!-- Returns the name of the latest watched anime --></nowiki>
  <nowiki>{{ fetchvar("$latestwatched_id" + @test2 + "_aname") }} <!-- Returns the name of the latest watched anime --></nowiki>
==== fsformat ====
''string'' '''fsformat'''(''number'' sizeInMiB[, ''number'' decimals[, ''boolean'' tenBasedExponents ]])
Formats the given file size according to the given parameters, using the most fitting unit for its size. File sizes should be expressed in MiB, as given by the system provided variables. The decimals argument specifies how many decimal numbers should be printed after the decimal point; the default value is 2. By default, 2<sup>n</sup> based units are used (1 GiB = 2<sup>10</sup> MiB = 1024 MiB), but this can be toggled to use 10<sup>n</sup> based units instead (1 GB = 10<sup>3</sup> MB = 1000 MB) by setting the third argument to true.
Example:
<nowiki>{{ fsformat(1024) }} <!-- Returns "1.00 GiB" --></nowiki>
<nowiki>{{ fsformat(1024, 2, true) }} <!-- Returns "1.02 GB" --></nowiki>
<nowiki>{{ fsformat(1048576, 0) }} <!-- Returns "1 TiB" --></nowiki>
<nowiki>{{ fsformat(1234, 6) }} <!-- Returns "1.205078 GiB" --></nowiki>


==== if ====
==== if ====
Line 242: Line 263:
==== lowercase ====
==== lowercase ====
  ''string'' '''lowercase'''(''mixed'' value[, ''string'' options])
  ''string'' '''lowercase'''(''mixed'' value[, ''string'' options])
If only first argument is specified it converts all the characters to lowercase. The second argument may be "first" or "words". If it is "first" only the string's first character will be converted. If it is set to "words", every word's first character will be converted.
If only first argument is specified it converts all the characters to lower case. The second argument may be "first" or "words". If it is "first" only the string's first character will be converted. If it is set to "words", every word's first character will be converted.


Example:
Example:
Line 287: Line 308:
  <nowiki>{{ truncate("Foobar", 4, "..") }} <!-- Returns "Fo.." --></nowiki>
  <nowiki>{{ truncate("Foobar", 4, "..") }} <!-- Returns "Fo.." --></nowiki>
  <nowiki>{{ truncate("Foob", 4, "..") }}  <!-- Returns "Foob" --></nowiki>
  <nowiki>{{ truncate("Foob", 4, "..") }}  <!-- Returns "Foob" --></nowiki>
==== truncatew ====
''string'' '''truncatew'''(''mixed'' string, ''number'' width[, ''string'' font[, ''number'' size[, ''string'' appendage]]])
Returns the string truncated to specified width in pixels. Default font is ''verdana''. Default size is ''12'' pixels. If ''appendage'' is set it will be appended when truncated.
Example:
<nowiki>{{ truncatew("Foobar", 60) }}                      <!-- Returns "Foobar" --></nowiki>
<nowiki>{{ truncatew("Foobar", 30) }}                      <!-- Returns "Foo" --></nowiki>
<nowiki>{{ truncatew("Foobar", 30, "comic", 10) }}        <!-- Returns "Foo" --></nowiki>
<nowiki>{{ truncatew("Foobar", 30, "comic", 10, "...") }}  <!-- Returns "Fo..." --></nowiki>


==== uc ====
==== uc ====
Line 293: Line 324:
==== uppercase ====
==== uppercase ====
  ''string'' '''uppercase'''(''mixed'' value[, ''string'' options])
  ''string'' '''uppercase'''(''mixed'' value[, ''string'' options])
If only first argument is specified it converts all the characters to uppercase. The second argument may be "first" or "words". If it is "first" only the string's first character will be converted. If it is set to "words", every word's first character will be converted.
If only first argument is specified it converts all the characters to upper case. The second argument may be "first" or "words". If it is "first" only the string's first character will be converted. If it is set to "words", every word's first character will be converted.


Example:
Example:
92

edits

Navigation menu

MediaWiki spam blocked by CleanTalk.
MediaWiki spam blocked by CleanTalk.