-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
daa662e
commit 052c844
Showing
26 changed files
with
745 additions
and
115 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2021 Broadcom. | ||
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Broadcom, Inc. - initial API and implementation | ||
*/ | ||
|
||
#include "aread_time.h" | ||
|
||
namespace { | ||
std::string zero_left_pad(std::string s, size_t len) | ||
{ | ||
if (s.size() >= len) | ||
return s; | ||
|
||
s.insert(s.begin(), len - s.size(), '0'); | ||
return s; | ||
} | ||
} // namespace | ||
|
||
|
||
std::string hlasm_plugin::parser_library::time_to_clockb(std::chrono::nanoseconds d) | ||
{ | ||
using namespace std::chrono; | ||
return zero_left_pad(std::to_string(duration_cast<milliseconds>(d).count() / 10), 8); | ||
} | ||
|
||
std::string hlasm_plugin::parser_library::time_to_clockd(std::chrono::nanoseconds d) | ||
{ | ||
using namespace std::chrono; | ||
std::string result; | ||
result.append(zero_left_pad(std::to_string(duration_cast<hours>(d).count()), 2)); | ||
result.append(zero_left_pad(std::to_string(duration_cast<minutes>(d).count() % 60), 2)); | ||
result.append(zero_left_pad(std::to_string(duration_cast<seconds>(d).count() % 60), 2)); | ||
result.append(zero_left_pad(std::to_string(duration_cast<milliseconds>(d).count() % 1000 / 10), 2)); | ||
return result; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2021 Broadcom. | ||
* The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Broadcom, Inc. - initial API and implementation | ||
*/ | ||
|
||
#ifndef HLASMPLUGIN_PARSERLIBRARY_AREAD_TIME_H | ||
#define HLASMPLUGIN_PARSERLIBRARY_AREAD_TIME_H | ||
|
||
#include <chrono> | ||
#include <string> | ||
|
||
namespace hlasm_plugin::parser_library { | ||
std::string time_to_clockb(std::chrono::nanoseconds d); | ||
std::string time_to_clockd(std::chrono::nanoseconds d); | ||
} // namespace hlasm_plugin::parser_library | ||
|
||
#endif // HLASMPLUGIN_PARSERLIBRARY_AREAD_TIME_H |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.