{"id":42679704,"url":"https://github.com/simatic-ax/conversion","last_synced_at":"2026-01-29T11:49:42.475Z","repository":{"id":116554836,"uuid":"452231460","full_name":"simatic-ax/conversion","owner":"simatic-ax","description":"Library: Include various converter-function variants like 'ToString', 'ToInt' or 'ToArrayOf'.","archived":false,"fork":false,"pushed_at":"2025-11-07T11:31:46.000Z","size":292,"stargazers_count":3,"open_issues_count":6,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-11-07T13:08:55.594Z","etag":null,"topics":["iec-st","library","siemens","simatic-ax"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simatic-ax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-01-26T10:25:57.000Z","updated_at":"2025-11-07T11:28:06.000Z","dependencies_parsed_at":"2023-07-08T06:18:24.071Z","dependency_job_id":"e4d1fd46-7eb1-4b7a-ab13-a102e7d66685","html_url":"https://github.com/simatic-ax/conversion","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/simatic-ax/conversion","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simatic-ax%2Fconversion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simatic-ax%2Fconversion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simatic-ax%2Fconversion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simatic-ax%2Fconversion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simatic-ax","download_url":"https://codeload.github.com/simatic-ax/conversion/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simatic-ax%2Fconversion/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28876845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T10:31:27.438Z","status":"ssl_error","status_checked_at":"2026-01-29T10:31:01.017Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iec-st","library","siemens","simatic-ax"],"created_at":"2026-01-29T11:49:41.827Z","updated_at":"2026-01-29T11:49:42.460Z","avatar_url":"https://github.com/simatic-ax.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# Conversion\r\n\r\n## Description\r\n\r\nThis library provides some functions to convert various data types and formats into other formats that are not covered by the built-in functionalities.\r\n\r\nCurrently, there are two categories:\r\n\r\n- Converting integer values to Strings and Strings to Integer values\r\n- Converting time formats from different systems\r\n\r\n## Install this package\r\n\r\nEnter:\r\n\r\n```cli\r\napax add @simatic-ax/conversion\r\n```\r\n\r\n\u003e to install this package you need to login into the GitHub registry. You'll find more information [here](https://github.com/simatic-ax/.github/blob/main/docs/personalaccesstoken.md)\r\n\r\n## Namespace\r\n\r\n```yml\r\nSimatic.Ax.Conversion;\r\nSimatic.Ax.Conversion.Integer;\r\nSimatic.Ax.Conversion.Strings;\r\nSimatic.Ax.Conversion.Times;\r\n```\r\n\r\n## ConversionMode for strings\r\n\r\n```iecst\r\nNAMESPACE Simatic.Ax.Conversion\r\n    TYPE\r\n        ConversionMode : WORD (\r\n            NONE := WORD#16#0000,\r\n            FORCE_SIGN := WORD#16#0001\r\n    END_TYPE\r\nEND_NAMESPACE\r\n```\r\n\r\n|Mode|Example|Result|\r\n|-|-|-|\r\n|NONE       | Integer.ToString(value := 123) | '123'\r\n|FORCE_SIGN | Integer.ToString(value := 123, mode := ConversionMode#FORCE_SIGN) | '+123'\r\n\r\n## Functions\r\n\r\n### ToString\r\n\r\n```iecst\r\nInteger.ToString(value :  SINT, mode : ConversionMode) : STRING[4];\r\nInteger.ToString(value : USINT, mode : ConversionMode) : STRING[4];\r\nInteger.ToString(value :   INT, mode : ConversionMode) : STRING[6];\r\nInteger.ToString(value :  UINT, mode : ConversionMode) : STRING[6];\r\nInteger.ToString(value :  DINT, mode : ConversionMode) : STRING[11];\r\nInteger.ToString(value : UDINT, mode : ConversionMode) : STRING[11];\r\nInteger.ToString(value :  LINT, mode : ConversionMode) : STRING[20];\r\nInteger.ToString(value : ULINT, mode : ConversionMode) : STRING[21];\r\n```\r\n\r\n### ToInt\r\n\r\n```iecst\r\nStrings.ToInt(str : STRING, value =\u003e  SINT) : BOOL;\r\nStrings.ToInt(str : STRING, value =\u003e   INT) : BOOL;\r\nStrings.ToInt(str : STRING, value =\u003e  DINT) : BOOL;\r\nStrings.ToInt(str : STRING, value =\u003e  LINT) : BOOL;\r\nStrings.ToInt(str : STRING, value =\u003e USINT) : BOOL;\r\nStrings.ToInt(str : STRING, value =\u003e  UINT) : BOOL;\r\nStrings.ToInt(str : STRING, value =\u003e UDINT) : BOOL;\r\n```\r\n\r\n### ToInt --\u003e ULINT\r\n\r\n```iecst\r\nStrings.ToInt(str : STRING, value =\u003e ULINT) : BOOL;\r\n```\r\n\r\n\u003e Values \u003e MAX ULINT will handled as MOD MAX_ULINT (MAX_ULINT = 18446744073709551615);\r\n\r\n### Simotion Date and Time of Day \u003c--\u003e LDT\r\n\r\n```iecst\r\n\r\nLDateAndTimeToSimotionDateToD(SimaticTime : LDATE_AND_TIME, SimotionTime =\u003e DWORD, SimotionDate =\u003e DWORD);\r\nSimotionDateToDToLDateAndTime(SimotionTime := DWORD, SimotionDate := DWORD) : LDATE_AND_TIME;\r\n```\r\n\r\n## Strings\r\n\r\n### Strings.ToHex\r\n\r\nThis function convert a string containing a hex number into a hex number\r\n\r\nExample:\r\n\r\n```iec-st\r\n    ret := Strings.ToHex(str := 'a231', n := 4, result =\u003e res);  // res = WORD#16#a231\r\n```\r\n\r\n| ReturnValue  | Explanation                                                |\r\n|--------------|------------------------------------------------------------|\r\n| WORD#16#0000 |  no error                                                  |\r\n| WORD#16#0007 |  invalid character                                         |\r\n| WORD#16#8182 |  Input buffer is too small for data in the N parameter     |\r\n| WORD#16#8482 |  Output buffer is too small for data in the N parameter    |\r\n\r\n### ToArray.OfCharCount\r\n\r\nDescription:\r\nThe function `ToArray.OfCharCount()` converts a string into a array of CHAR\r\n\r\n- When the string is longer than the array, then the string will be cut. The function returns the length of the array.\r\n- When the string is shorter then the array. The complete string can be copied to the array. The elements behind will not be touched. The function returns the length of the string\r\n- arrays with other start index than 0 are supported\r\n- only one dimensional arrays are supported\r\n\r\n```iecst\r\nStrings.ToArray.OfCharCount(str : STRING, arr : ARRAY[*] OF CHAR) : DINT;\r\n```\r\n\r\n|||\r\n|-|-|\r\n| ToArray.OfCharCount() : DINT | Returns the number of copied characters\r\n|str : STRING| Source string |\r\n|arr : ARRAY[*] OF CHAR| Destination array |\r\n\r\n### ToArray.OfLint\r\n\r\n```iec-st\r\nStrings.ToArray.OfLint(str : STRING, arr : ARRAY[*] of LINT) : BOOL;\r\n```\r\n\r\nConvert a String \"[123, 456, 789]\" to an ARRAY[*] OF LINT and returns TRUE if the conversion was successful. If the target array `arr` is to small, the function returns also `true` but converts not more elements than the size of the destination array. If you want the number of converted elements, then ist the function `ToArray.OfLintCount()`\r\n\r\n### ToArray.OfLintCount\r\n\r\n```iec-st\r\nStrings.ToArray.OfLintCount(str : STRING, arr : ARRAY[*] of LINT) : DINT;\r\n```\r\n\r\nConvert a String \"[123, 456, 789]\" to an ARRAY[*] OF LINT and returns the number of converted elements,\r\n\r\n### Arrays.ToString\r\n\r\n|||\r\n|-|-|\r\n| ToArray() : STRING | Returns the string created of the array. Arrays \u003e 254 elements will be cut off\r\n|arr : ARRAY[*] OF CHAR| Source array |\r\n|startIdx : INT | Start index|\r\n|endIdx : INT | End index|\r\n\r\n\u003e when startIdx and endIdx are not used, the whole array until max string length will be copied.\r\n\u003e Implausible indices will return a empty string. Examples:\r\n\u003e\r\n\u003e - startIdx \u003e endIdx\r\n\u003e - startIdx out of the array boundaries startIdx : 1 and Array[5..10]\r\n\u003e - endIdx out of the array boundaries endIdx : 15 and Array[0..10]\r\n\r\n## TRUNC\r\n\r\nTRUNC() round a floating number no the next DINT value downwards to zero\r\n\r\n```iecst\r\nTRUNC(value : LREAL) : DINT;\r\nTRUNC(value : REAL) : DINT;\r\n```\r\n\r\n### Times\r\n\r\nConvert the date and time of a SIMOTION system into the data type LDATE_AND_TIME (LDT) and back. The SIMOTION format is a structured data type consisting of two 32-bit values. For the sake of simplicity, they are interpeted as DWORD.\r\n\r\n```iecst\r\nNAMESPACE Simatic.Ax.Conversion.Times\r\n    TYPE \r\n        SimotionDateTime : STRUCT\r\n            SimotionTime : DWORD;\r\n            SimotionDate : DWORD;\r\n        END_STRUCT;\r\n    END_TYPE\r\nEND_NAMESPACE\r\n```\r\n\r\n|||\r\n|-|-|\r\n|SimotionTime : DWORD|Milliseconds that have passed on the current day|\r\n|SimotionDate : DWORD|Days that have passed since 1992-01-01|\r\n|SimaticTime : LDATE_AND_TIME|Nanoseconds that have passed since 1970-01-01-00:00:00.000|\r\n\r\n## Contribution\r\n\r\nThanks for your interest in contributing. Anybody is free to report bugs, unclear documentation, and other problems regarding this repository in the Issues section or, even better, is free to propose any changes to this repository using Merge Requests.\r\n\r\n## Markdownlint-cli\r\n\r\nThis workspace will be checked by the [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) (there is also documented ho to install the tool) tool in the CI workflow automatically.\r\nTo avoid, that the CI workflow fails because of the markdown linter, you can check all markdown files locally by running the markdownlint with:\r\n\r\n```sh\r\nmarkdownlint **/*.md --fix\r\n```\r\n\r\n## License and Legal information\r\n\r\nPlease read the [Legal information](LICENSE.md)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimatic-ax%2Fconversion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimatic-ax%2Fconversion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimatic-ax%2Fconversion/lists"}