Last active
December 29, 2023 12:07
-
-
Save sorgfal/c7b9becec1bc29c87a2d3adc97e458da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'dart:convert'; | |
| import 'dart:typed_data'; | |
| void main() { | |
| final items = [ | |
| 'DDX_d979bdf8_ZYmCXg==', | |
| 'DDX_70f1633c_ZYly9w==', | |
| 'DDX_fc47a14c_ZYly/Q==', | |
| 'DDX_7b8ca1ea_ZYmCdQ==', | |
| 'DDX_5b93a84b_ZYlzLQ==', | |
| 'DDX_35014a0a_ZYlzdw==', | |
| 'DDX_6f496d75_ZYmCeg==', | |
| 'DDX_5971b2e6_ZYlx6Q==', | |
| 'DDX_9e78b8e9_ZYlzMA==', | |
| 'DDX_57deb8a6_ZYmCmA==', | |
| ]; | |
| for (final t in items) { | |
| print(decodeComponents(t)); | |
| } | |
| } | |
| ({ | |
| String head, | |
| String hash, | |
| String stamp, | |
| String view, | |
| String utcView | |
| }) decodeComponents(String input) { | |
| /// Режем строку по разделителю. Получаем 3 компонента | |
| final inputComponents = input.split('_'); | |
| print(inputComponents); | |
| /// Делаю decode из base64 | |
| final stamp = base64.decode(inputComponents[2]); | |
| print(stamp); | |
| /// Меняю тип представления из массива байтов на uint32 | |
| final stampInt = stamp.buffer.asByteData().getUint32(0, Endian.big); | |
| print(stampInt); | |
| /// парсинг значения | |
| final timestampView = DateTime.fromMillisecondsSinceEpoch(stampInt * 1000); | |
| return ( | |
| head: inputComponents[0], | |
| hash: inputComponents[1], | |
| stamp: stampInt.toString(), | |
| view: timestampView.toIso8601String(), | |
| utcView: timestampView.toUtc().toIso8601String() | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment