diff --git a/LICENSE b/LICENSE
index 65c5ca8..0040033 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,165 +1,21 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc.
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
- This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
- 0. Additional Definitions.
-
- As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
- "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
- An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
- A "Combined Work" is a work produced by combining or linking an
-Application with the Library. The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
- The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
- The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
- 1. Exception to Section 3 of the GNU GPL.
-
- You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
- 2. Conveying Modified Versions.
-
- If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
- a) under this License, provided that you make a good faith effort to
- ensure that, in the event an Application does not supply the
- function or data, the facility still operates, and performs
- whatever part of its purpose remains meaningful, or
-
- b) under the GNU GPL, with none of the additional permissions of
- this License applicable to that copy.
-
- 3. Object Code Incorporating Material from Library Header Files.
-
- The object code form of an Application may incorporate material from
-a header file that is part of the Library. You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
- a) Give prominent notice with each copy of the object code that the
- Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the object code with a copy of the GNU GPL and this license
- document.
-
- 4. Combined Works.
-
- You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
- a) Give prominent notice with each copy of the Combined Work that
- the Library is used in it and that the Library and its use are
- covered by this License.
-
- b) Accompany the Combined Work with a copy of the GNU GPL and this license
- document.
-
- c) For a Combined Work that displays copyright notices during
- execution, include the copyright notice for the Library among
- these notices, as well as a reference directing the user to the
- copies of the GNU GPL and this license document.
-
- d) Do one of the following:
-
- 0) Convey the Minimal Corresponding Source under the terms of this
- License, and the Corresponding Application Code in a form
- suitable for, and under terms that permit, the user to
- recombine or relink the Application with a modified version of
- the Linked Version to produce a modified Combined Work, in the
- manner specified by section 6 of the GNU GPL for conveying
- Corresponding Source.
-
- 1) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (a) uses at run time
- a copy of the Library already present on the user's computer
- system, and (b) will operate properly with a modified version
- of the Library that is interface-compatible with the Linked
- Version.
-
- e) Provide Installation Information, but only if you would otherwise
- be required to provide such information under section 6 of the
- GNU GPL, and only to the extent that such information is
- necessary to install and execute a modified version of the
- Combined Work produced by recombining or relinking the
- Application with a modified version of the Linked Version. (If
- you use option 4d0, the Installation Information must accompany
- the Minimal Corresponding Source and Corresponding Application
- Code. If you use option 4d1, you must provide the Installation
- Information in the manner specified by section 6 of the GNU GPL
- for conveying Corresponding Source.)
-
- 5. Combined Libraries.
-
- You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
- a) Accompany the combined library with a copy of the same work based
- on the Library, uncombined with any other library facilities,
- conveyed under the terms of this License.
-
- b) Give prominent notice with the combined library that part of it
- is a work based on the Library, and explaining where to find the
- accompanying uncombined form of the same work.
-
- 6. Revised Versions of the GNU Lesser General Public License.
-
- The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
- If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
+MIT License
+
+Copyright (c) 2018 The Officious BokkyPooBah / Bok Consulting Pty Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index 3cc397c..03fffa2 100644
--- a/README.md
+++ b/README.md
@@ -81,10 +81,11 @@ Version | Date | Notes
:------------------ |:------------ |:---------------------------------------
v1.00-pre-release | May 25 2018 | "Rarefaction" pre-release. I'm currently trying to get this library audited, so don't use in production mode yet.
v1.00-pre-release-a | Jun 2 2018 | "Rarefaction" pre-release a. Added the [contracts/BokkyPooBahsDateTimeContract.sol](contracts/BokkyPooBahsDateTimeContract.sol) wrapper for convenience. [Alex Kampa](https://github.com/alex-kampa) conducted a range of [tests](https://github.com/alex-kampa/test_BokkyPooBahsDateTimeLibrary) on the library.
-v1.00-pre-release-b | Jun 4 2018 | "Rarefaction" pre-release b. Replaced public function with internal for easier EtherScan verification - [a83e13b](https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary/commit/a83e13bef31e8ef399007dd237e42bd5cdf479e6) . Deployed [contracts/BokkyPooBahsDateTimeContract.sol](contracts/BokkyPooBahsDateTimeContract.sol) with the inlined [contracts/BokkyPooBahsDateTimeLibrary.sol](contracts/BokkyPooBahsDateTimeLibrary.sol) to the [Ropsten network](deployment/deployment-v1.00-prerelease.md) at address [0x07239bb079094481bfaac91ca842426860021aaa](https://ropsten.etherscan.io/address/0x07239bb079094481bfaac91ca842426860021aaa#code)
+v1.00-pre-release-b | Jun 4 2018 | "Rarefaction" pre-release b. Replaced public function with internal for easier EtherScan verification - [a83e13b](https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary/commit/a83e13bef31e8ef399007dd237e42bd5cdf479e6). Deployed [contracts/BokkyPooBahsDateTimeContract.sol](contracts/BokkyPooBahsDateTimeContract.sol) with the inlined [contracts/BokkyPooBahsDateTimeLibrary.sol](contracts/BokkyPooBahsDateTimeLibrary.sol) to the [Ropsten network](deployment/deployment-v1.00-prerelease.md) at address [0x07239bb079094481bfaac91ca842426860021aaa](https://ropsten.etherscan.io/address/0x07239bb079094481bfaac91ca842426860021aaa#code)
v1.00-pre-release-c | June 8 2018 | "Rarefaction" pre-release c. Added `require(year >= 1970)` to `_daysFromDate(...)` in [4002b27](https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary/commit/4002b278d1779fcd4f3f4527a60a5887ee6c20ba) as highlighted in [James Zaki](https://github.com/jzaki)'s audit
v1.00-pre-release-d | Sep 1 2018 | "Rarefaction" pre-release d. Added [isValidDate(...)](#isvaliddate) and [isValidDateTime(...)](#isvaliddatetime) in [380061b](https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary/commit/380061b9d20c83450ee303f709fe58e973c5f4a9) as highlighted in [Adrian Guerrera](https://github.com/apguerrera)'s audit
v1.00 | Sep 2 2018 | "Rarefaction" release
+v1.01 | Feb 14 2019 | "Notoryctes" release. Upgraded contracts to Solidity 0.5.x. Updated to MIT Licence
@@ -156,7 +157,7 @@ And from the second answer to [Unix time and leap seconds](https://stackoverflow
>
> That is, there are some duplicate timestamps representing two different seconds in time, because in unix time the sixtieth second might have to repeat itself (as there can't be a sixty-first second). Theoretically, they could also be gaps in the future because the sixtieth second doesn't have to exist, although no skipping leap seconds have been issued so far.
>
-> Rationale for unix time: it's defined so that it's easy to work with. Adding support for leap seconds to the standard libraries is very tricky.
+> Rationale for unix time: it's defined so that it's easy to work with. Adding support for leap seconds to the standard libraries is very tricky.
> ...
This library aims to replicate the [Unix time](https://en.wikipedia.org/wiki/Unix_time) functionality and assumes that leap seconds are handled by the underlying operating system.
@@ -899,4 +900,4 @@ A copy of the webpage with the algorithm [Converting Between Julian Dates and Gr
Enjoy!
-(c) BokkyPooBah / Bok Consulting Pty Ltd - Sep 2 2018. [GNU Lesser General Public License 3.0](https://www.gnu.org/licenses/lgpl-3.0.en.html)
\ No newline at end of file
+(c) BokkyPooBah / Bok Consulting Pty Ltd - Feb 14 2019. The MIT Licence.
diff --git a/contracts/BokkyPooBahsDateTimeLibrary.sol b/contracts/BokkyPooBahsDateTimeLibrary.sol
index 2823f99..01e4375 100644
--- a/contracts/BokkyPooBahsDateTimeLibrary.sol
+++ b/contracts/BokkyPooBahsDateTimeLibrary.sol
@@ -1,7 +1,7 @@
-pragma solidity ^0.4.24;
+pragma solidity ^0.5.0;
// ----------------------------------------------------------------------------
-// BokkyPooBah's DateTime Library v1.00
+// BokkyPooBah's DateTime Library v1.01
//
// A gas-efficient Solidity date and time library
//
@@ -22,10 +22,7 @@ pragma solidity ^0.4.24;
// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday
//
//
-// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018.
-//
-// GNU Lesser General Public License 3.0
-// https://www.gnu.org/licenses/lgpl-3.0.en.html
+// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.
// ----------------------------------------------------------------------------
library BokkyPooBahsDateTimeLibrary {
@@ -336,4 +333,4 @@ library BokkyPooBahsDateTimeLibrary {
require(fromTimestamp <= toTimestamp);
_seconds = toTimestamp - fromTimestamp;
}
-}
\ No newline at end of file
+}
diff --git a/contracts/TestDateTime.sol b/contracts/TestDateTime.sol
index 35bd201..071750a 100644
--- a/contracts/TestDateTime.sol
+++ b/contracts/TestDateTime.sol
@@ -1,4 +1,4 @@
-pragma solidity ^0.4.23;
+pragma solidity ^0.5.0;
import "BokkyPooBahsDateTimeLibrary.sol";
@@ -7,10 +7,7 @@ import "BokkyPooBahsDateTimeLibrary.sol";
//
// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
//
-// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018.
-//
-// GNU Lesser General Public License 3.0
-// https://www.gnu.org/licenses/lgpl-3.0.en.html
+// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.
// ----------------------------------------------------------------------------
contract TestDateTime {
@@ -141,4 +138,4 @@ contract TestDateTime {
function diffSeconds(uint fromTimestamp, uint toTimestamp) public pure returns (uint _seconds) {
_seconds = BokkyPooBahsDateTimeLibrary.diffSeconds(fromTimestamp, toTimestamp);
}
-}
\ No newline at end of file
+}
diff --git a/flattened/TestDateTime_flattened.sol b/flattened/TestDateTime_flattened.sol
new file mode 100644
index 0000000..c7019e7
--- /dev/null
+++ b/flattened/TestDateTime_flattened.sol
@@ -0,0 +1,475 @@
+pragma solidity ^0.5.0;
+
+
+// ----------------------------------------------------------------------------
+// BokkyPooBah's DateTime Library v1.01
+//
+// A gas-efficient Solidity date and time library
+//
+// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
+//
+// Tested date range 1970/01/01 to 2345/12/31
+//
+// Conventions:
+// Unit | Range | Notes
+// :-------- |:-------------:|:-----
+// timestamp | >= 0 | Unix timestamp, number of seconds since 1970/01/01 00:00:00 UTC
+// year | 1970 ... 2345 |
+// month | 1 ... 12 |
+// day | 1 ... 31 |
+// hour | 0 ... 23 |
+// minute | 0 ... 59 |
+// second | 0 ... 59 |
+// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday
+//
+//
+// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.
+// ----------------------------------------------------------------------------
+
+library BokkyPooBahsDateTimeLibrary {
+
+ uint constant SECONDS_PER_DAY = 24 * 60 * 60;
+ uint constant SECONDS_PER_HOUR = 60 * 60;
+ uint constant SECONDS_PER_MINUTE = 60;
+ int constant OFFSET19700101 = 2440588;
+
+ uint constant DOW_MON = 1;
+ uint constant DOW_TUE = 2;
+ uint constant DOW_WED = 3;
+ uint constant DOW_THU = 4;
+ uint constant DOW_FRI = 5;
+ uint constant DOW_SAT = 6;
+ uint constant DOW_SUN = 7;
+
+ // ------------------------------------------------------------------------
+ // Calculate the number of days from 1970/01/01 to year/month/day using
+ // the date conversion algorithm from
+ // http://aa.usno.navy.mil/faq/docs/JD_Formula.php
+ // and subtracting the offset 2440588 so that 1970/01/01 is day 0
+ //
+ // days = day
+ // - 32075
+ // + 1461 * (year + 4800 + (month - 14) / 12) / 4
+ // + 367 * (month - 2 - (month - 14) / 12 * 12) / 12
+ // - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4
+ // - offset
+ // ------------------------------------------------------------------------
+ function _daysFromDate(uint year, uint month, uint day) internal pure returns (uint _days) {
+ require(year >= 1970);
+ int _year = int(year);
+ int _month = int(month);
+ int _day = int(day);
+
+ int __days = _day
+ - 32075
+ + 1461 * (_year + 4800 + (_month - 14) / 12) / 4
+ + 367 * (_month - 2 - (_month - 14) / 12 * 12) / 12
+ - 3 * ((_year + 4900 + (_month - 14) / 12) / 100) / 4
+ - OFFSET19700101;
+
+ _days = uint(__days);
+ }
+
+ // ------------------------------------------------------------------------
+ // Calculate year/month/day from the number of days since 1970/01/01 using
+ // the date conversion algorithm from
+ // http://aa.usno.navy.mil/faq/docs/JD_Formula.php
+ // and adding the offset 2440588 so that 1970/01/01 is day 0
+ //
+ // int L = days + 68569 + offset
+ // int N = 4 * L / 146097
+ // L = L - (146097 * N + 3) / 4
+ // year = 4000 * (L + 1) / 1461001
+ // L = L - 1461 * year / 4 + 31
+ // month = 80 * L / 2447
+ // dd = L - 2447 * month / 80
+ // L = month / 11
+ // month = month + 2 - 12 * L
+ // year = 100 * (N - 49) + year + L
+ // ------------------------------------------------------------------------
+ function _daysToDate(uint _days) internal pure returns (uint year, uint month, uint day) {
+ int __days = int(_days);
+
+ int L = __days + 68569 + OFFSET19700101;
+ int N = 4 * L / 146097;
+ L = L - (146097 * N + 3) / 4;
+ int _year = 4000 * (L + 1) / 1461001;
+ L = L - 1461 * _year / 4 + 31;
+ int _month = 80 * L / 2447;
+ int _day = L - 2447 * _month / 80;
+ L = _month / 11;
+ _month = _month + 2 - 12 * L;
+ _year = 100 * (N - 49) + _year + L;
+
+ year = uint(_year);
+ month = uint(_month);
+ day = uint(_day);
+ }
+
+ function timestampFromDate(uint year, uint month, uint day) internal pure returns (uint timestamp) {
+ timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY;
+ }
+ function timestampFromDateTime(uint year, uint month, uint day, uint hour, uint minute, uint second) internal pure returns (uint timestamp) {
+ timestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + hour * SECONDS_PER_HOUR + minute * SECONDS_PER_MINUTE + second;
+ }
+ function timestampToDate(uint timestamp) internal pure returns (uint year, uint month, uint day) {
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ }
+ function timestampToDateTime(uint timestamp) internal pure returns (uint year, uint month, uint day, uint hour, uint minute, uint second) {
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ uint secs = timestamp % SECONDS_PER_DAY;
+ hour = secs / SECONDS_PER_HOUR;
+ secs = secs % SECONDS_PER_HOUR;
+ minute = secs / SECONDS_PER_MINUTE;
+ second = secs % SECONDS_PER_MINUTE;
+ }
+
+ function isValidDate(uint year, uint month, uint day) internal pure returns (bool valid) {
+ if (year >= 1970 && month > 0 && month <= 12) {
+ uint daysInMonth = _getDaysInMonth(year, month);
+ if (day > 0 && day <= daysInMonth) {
+ valid = true;
+ }
+ }
+ }
+ function isValidDateTime(uint year, uint month, uint day, uint hour, uint minute, uint second) internal pure returns (bool valid) {
+ if (isValidDate(year, month, day)) {
+ if (hour < 24 && minute < 60 && second < 60) {
+ valid = true;
+ }
+ }
+ }
+ function isLeapYear(uint timestamp) internal pure returns (bool leapYear) {
+ uint year;
+ uint month;
+ uint day;
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ leapYear = _isLeapYear(year);
+ }
+ function _isLeapYear(uint year) internal pure returns (bool leapYear) {
+ leapYear = ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
+ }
+ function isWeekDay(uint timestamp) internal pure returns (bool weekDay) {
+ weekDay = getDayOfWeek(timestamp) <= DOW_FRI;
+ }
+ function isWeekEnd(uint timestamp) internal pure returns (bool weekEnd) {
+ weekEnd = getDayOfWeek(timestamp) >= DOW_SAT;
+ }
+ function getDaysInMonth(uint timestamp) internal pure returns (uint daysInMonth) {
+ uint year;
+ uint month;
+ uint day;
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ daysInMonth = _getDaysInMonth(year, month);
+ }
+ function _getDaysInMonth(uint year, uint month) internal pure returns (uint daysInMonth) {
+ if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
+ daysInMonth = 31;
+ } else if (month != 2) {
+ daysInMonth = 30;
+ } else {
+ daysInMonth = _isLeapYear(year) ? 29 : 28;
+ }
+ }
+ // 1 = Monday, 7 = Sunday
+ function getDayOfWeek(uint timestamp) internal pure returns (uint dayOfWeek) {
+ uint _days = timestamp / SECONDS_PER_DAY;
+ dayOfWeek = (_days + 3) % 7 + 1;
+ }
+
+ function getYear(uint timestamp) internal pure returns (uint year) {
+ uint month;
+ uint day;
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ }
+ function getMonth(uint timestamp) internal pure returns (uint month) {
+ uint year;
+ uint day;
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ }
+ function getDay(uint timestamp) internal pure returns (uint day) {
+ uint year;
+ uint month;
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ }
+ function getHour(uint timestamp) internal pure returns (uint hour) {
+ uint secs = timestamp % SECONDS_PER_DAY;
+ hour = secs / SECONDS_PER_HOUR;
+ }
+ function getMinute(uint timestamp) internal pure returns (uint minute) {
+ uint secs = timestamp % SECONDS_PER_HOUR;
+ minute = secs / SECONDS_PER_MINUTE;
+ }
+ function getSecond(uint timestamp) internal pure returns (uint second) {
+ second = timestamp % SECONDS_PER_MINUTE;
+ }
+
+ function addYears(uint timestamp, uint _years) internal pure returns (uint newTimestamp) {
+ uint year;
+ uint month;
+ uint day;
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ year += _years;
+ uint daysInMonth = _getDaysInMonth(year, month);
+ if (day > daysInMonth) {
+ day = daysInMonth;
+ }
+ newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
+ require(newTimestamp >= timestamp);
+ }
+ function addMonths(uint timestamp, uint _months) internal pure returns (uint newTimestamp) {
+ uint year;
+ uint month;
+ uint day;
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ month += _months;
+ year += (month - 1) / 12;
+ month = (month - 1) % 12 + 1;
+ uint daysInMonth = _getDaysInMonth(year, month);
+ if (day > daysInMonth) {
+ day = daysInMonth;
+ }
+ newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
+ require(newTimestamp >= timestamp);
+ }
+ function addDays(uint timestamp, uint _days) internal pure returns (uint newTimestamp) {
+ newTimestamp = timestamp + _days * SECONDS_PER_DAY;
+ require(newTimestamp >= timestamp);
+ }
+ function addHours(uint timestamp, uint _hours) internal pure returns (uint newTimestamp) {
+ newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;
+ require(newTimestamp >= timestamp);
+ }
+ function addMinutes(uint timestamp, uint _minutes) internal pure returns (uint newTimestamp) {
+ newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;
+ require(newTimestamp >= timestamp);
+ }
+ function addSeconds(uint timestamp, uint _seconds) internal pure returns (uint newTimestamp) {
+ newTimestamp = timestamp + _seconds;
+ require(newTimestamp >= timestamp);
+ }
+
+ function subYears(uint timestamp, uint _years) internal pure returns (uint newTimestamp) {
+ uint year;
+ uint month;
+ uint day;
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ year -= _years;
+ uint daysInMonth = _getDaysInMonth(year, month);
+ if (day > daysInMonth) {
+ day = daysInMonth;
+ }
+ newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
+ require(newTimestamp <= timestamp);
+ }
+ function subMonths(uint timestamp, uint _months) internal pure returns (uint newTimestamp) {
+ uint year;
+ uint month;
+ uint day;
+ (year, month, day) = _daysToDate(timestamp / SECONDS_PER_DAY);
+ uint yearMonth = year * 12 + (month - 1) - _months;
+ year = yearMonth / 12;
+ month = yearMonth % 12 + 1;
+ uint daysInMonth = _getDaysInMonth(year, month);
+ if (day > daysInMonth) {
+ day = daysInMonth;
+ }
+ newTimestamp = _daysFromDate(year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
+ require(newTimestamp <= timestamp);
+ }
+ function subDays(uint timestamp, uint _days) internal pure returns (uint newTimestamp) {
+ newTimestamp = timestamp - _days * SECONDS_PER_DAY;
+ require(newTimestamp <= timestamp);
+ }
+ function subHours(uint timestamp, uint _hours) internal pure returns (uint newTimestamp) {
+ newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;
+ require(newTimestamp <= timestamp);
+ }
+ function subMinutes(uint timestamp, uint _minutes) internal pure returns (uint newTimestamp) {
+ newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;
+ require(newTimestamp <= timestamp);
+ }
+ function subSeconds(uint timestamp, uint _seconds) internal pure returns (uint newTimestamp) {
+ newTimestamp = timestamp - _seconds;
+ require(newTimestamp <= timestamp);
+ }
+
+ function diffYears(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _years) {
+ require(fromTimestamp <= toTimestamp);
+ uint fromYear;
+ uint fromMonth;
+ uint fromDay;
+ uint toYear;
+ uint toMonth;
+ uint toDay;
+ (fromYear, fromMonth, fromDay) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);
+ (toYear, toMonth, toDay) = _daysToDate(toTimestamp / SECONDS_PER_DAY);
+ _years = toYear - fromYear;
+ }
+ function diffMonths(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _months) {
+ require(fromTimestamp <= toTimestamp);
+ uint fromYear;
+ uint fromMonth;
+ uint fromDay;
+ uint toYear;
+ uint toMonth;
+ uint toDay;
+ (fromYear, fromMonth, fromDay) = _daysToDate(fromTimestamp / SECONDS_PER_DAY);
+ (toYear, toMonth, toDay) = _daysToDate(toTimestamp / SECONDS_PER_DAY);
+ _months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;
+ }
+ function diffDays(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _days) {
+ require(fromTimestamp <= toTimestamp);
+ _days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;
+ }
+ function diffHours(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _hours) {
+ require(fromTimestamp <= toTimestamp);
+ _hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;
+ }
+ function diffMinutes(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _minutes) {
+ require(fromTimestamp <= toTimestamp);
+ _minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;
+ }
+ function diffSeconds(uint fromTimestamp, uint toTimestamp) internal pure returns (uint _seconds) {
+ require(fromTimestamp <= toTimestamp);
+ _seconds = toTimestamp - fromTimestamp;
+ }
+}
+
+// ----------------------------------------------------------------------------
+// Testing BokkyPooBah's DateTime Library
+//
+// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
+//
+// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.
+// ----------------------------------------------------------------------------
+
+contract TestDateTime {
+ using BokkyPooBahsDateTimeLibrary for uint;
+
+ uint public nextYear;
+
+ function test() public {
+ uint today = now;
+ nextYear = today.addYears(1);
+ }
+
+ function timestampFromDate(uint year, uint month, uint day) public pure returns (uint timestamp) {
+ return BokkyPooBahsDateTimeLibrary.timestampFromDate(year, month, day);
+ }
+ function timestampFromDateTime(uint year, uint month, uint day, uint hour, uint minute, uint second) public pure returns (uint timestamp) {
+ return BokkyPooBahsDateTimeLibrary.timestampFromDateTime(year, month, day, hour, minute, second);
+ }
+ function timestampToDate(uint timestamp) public pure returns (uint year, uint month, uint day) {
+ (year, month, day) = BokkyPooBahsDateTimeLibrary.timestampToDate(timestamp);
+ }
+ function timestampToDateTime(uint timestamp) public pure returns (uint year, uint month, uint day, uint hour, uint minute, uint second) {
+ (year, month, day, hour, minute, second) = BokkyPooBahsDateTimeLibrary.timestampToDateTime(timestamp);
+ }
+
+ function isLeapYear(uint timestamp) public pure returns (bool leapYear) {
+ leapYear = BokkyPooBahsDateTimeLibrary.isLeapYear(timestamp);
+ }
+ function _isLeapYear(uint year) public pure returns (bool leapYear) {
+ leapYear = BokkyPooBahsDateTimeLibrary._isLeapYear(year);
+ }
+ function isWeekDay(uint timestamp) public pure returns (bool weekDay) {
+ weekDay = BokkyPooBahsDateTimeLibrary.isWeekDay(timestamp);
+ }
+ function isWeekEnd(uint timestamp) public pure returns (bool weekEnd) {
+ weekEnd = BokkyPooBahsDateTimeLibrary.isWeekEnd(timestamp);
+ }
+
+ function getDaysInMonth(uint timestamp) public pure returns (uint daysInMonth) {
+ daysInMonth = BokkyPooBahsDateTimeLibrary.getDaysInMonth(timestamp);
+ }
+ function _getDaysInMonth(uint year, uint month) public pure returns (uint daysInMonth) {
+ daysInMonth = BokkyPooBahsDateTimeLibrary._getDaysInMonth(year, month);
+ }
+ function getDayOfWeek(uint timestamp) public pure returns (uint dayOfWeek) {
+ dayOfWeek = BokkyPooBahsDateTimeLibrary.getDayOfWeek(timestamp);
+ }
+
+ function isValidDate(uint year, uint month, uint day) public pure returns (bool valid) {
+ valid = BokkyPooBahsDateTimeLibrary.isValidDate(year, month, day);
+ }
+ function isValidDateTime(uint year, uint month, uint day, uint hour, uint minute, uint second) public pure returns (bool valid) {
+ valid = BokkyPooBahsDateTimeLibrary.isValidDateTime(year, month, day, hour, minute, second);
+ }
+
+ function getYear(uint timestamp) public pure returns (uint year) {
+ year = BokkyPooBahsDateTimeLibrary.getYear(timestamp);
+ }
+ function getMonth(uint timestamp) public pure returns (uint month) {
+ month = BokkyPooBahsDateTimeLibrary.getMonth(timestamp);
+ }
+ function getDay(uint timestamp) public pure returns (uint day) {
+ day = BokkyPooBahsDateTimeLibrary.getDay(timestamp);
+ }
+ function getHour(uint timestamp) public pure returns (uint hour) {
+ hour = BokkyPooBahsDateTimeLibrary.getHour(timestamp);
+ }
+ function getMinute(uint timestamp) public pure returns (uint minute) {
+ minute = BokkyPooBahsDateTimeLibrary.getMinute(timestamp);
+ }
+ function getSecond(uint timestamp) public pure returns (uint second) {
+ second = BokkyPooBahsDateTimeLibrary.getSecond(timestamp);
+ }
+
+ function addYears(uint timestamp, uint _years) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.addYears(timestamp, _years);
+ }
+ function addMonths(uint timestamp, uint _months) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.addMonths(timestamp, _months);
+ }
+ function addDays(uint timestamp, uint _days) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.addDays(timestamp, _days);
+ }
+ function addHours(uint timestamp, uint _hours) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.addHours(timestamp, _hours);
+ }
+ function addMinutes(uint timestamp, uint _minutes) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.addMinutes(timestamp, _minutes);
+ }
+ function addSeconds(uint timestamp, uint _seconds) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.addSeconds(timestamp, _seconds);
+ }
+
+ function subYears(uint timestamp, uint _years) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.subYears(timestamp, _years);
+ }
+ function subMonths(uint timestamp, uint _months) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.subMonths(timestamp, _months);
+ }
+ function subDays(uint timestamp, uint _days) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.subDays(timestamp, _days);
+ }
+ function subHours(uint timestamp, uint _hours) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.subHours(timestamp, _hours);
+ }
+ function subMinutes(uint timestamp, uint _minutes) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.subMinutes(timestamp, _minutes);
+ }
+ function subSeconds(uint timestamp, uint _seconds) public pure returns (uint newTimestamp) {
+ newTimestamp = BokkyPooBahsDateTimeLibrary.subSeconds(timestamp, _seconds);
+ }
+
+ function diffYears(uint fromTimestamp, uint toTimestamp) public pure returns (uint _years) {
+ _years = BokkyPooBahsDateTimeLibrary.diffYears(fromTimestamp, toTimestamp);
+ }
+ function diffMonths(uint fromTimestamp, uint toTimestamp) public pure returns (uint _months) {
+ _months = BokkyPooBahsDateTimeLibrary.diffMonths(fromTimestamp, toTimestamp);
+ }
+ function diffDays(uint fromTimestamp, uint toTimestamp) public pure returns (uint _days) {
+ _days = BokkyPooBahsDateTimeLibrary.diffDays(fromTimestamp, toTimestamp);
+ }
+ function diffHours(uint fromTimestamp, uint toTimestamp) public pure returns (uint _hours) {
+ _hours = BokkyPooBahsDateTimeLibrary.diffHours(fromTimestamp, toTimestamp);
+ }
+ function diffMinutes(uint fromTimestamp, uint toTimestamp) public pure returns (uint _minutes) {
+ _minutes = BokkyPooBahsDateTimeLibrary.diffMinutes(fromTimestamp, toTimestamp);
+ }
+ function diffSeconds(uint fromTimestamp, uint toTimestamp) public pure returns (uint _seconds) {
+ _seconds = BokkyPooBahsDateTimeLibrary.diffSeconds(fromTimestamp, toTimestamp);
+ }
+}
diff --git a/scripts/solidityFlattener.pl b/scripts/solidityFlattener.pl
new file mode 100755
index 0000000..15c2fd0
--- /dev/null
+++ b/scripts/solidityFlattener.pl
@@ -0,0 +1,138 @@
+#!/usr/bin/perl -W
+# ----------------------------------------------------------------------------------------------
+# Solidity Flattener v1.0.2
+#
+# https://github.com/bokkypoobah/SolidityFlattener
+#
+# Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018. The MIT Licence.
+# ----------------------------------------------------------------------------------------------
+
+use strict;
+use Getopt::Long qw(:config no_auto_abbrev);
+use File::Basename;
+use File::Spec::Functions;
+
+my $DEFAULTCONTRACTSDIR = "./contracts";
+my $VERSION = "v1.0.3";
+
+my $helptext = qq\
+Solidity Flattener $VERSION
+
+Usage: $0 {options}
+
+Where options are:
+ --contractsdir Source directory for original contracts. Default '$DEFAULTCONTRACTSDIR'
+ --remapdir Remap import directories. Optional. Example "contracts/openzeppelin-solidity=node_modules/openzeppelin-solidity"
+ --mainsol Main source Solidity file. Mandatory
+ --outputsol Output flattened Solidity file. Default is mainsol with `_flattened` appended to the file name
+ --verbose Show details. Optional
+ --help Display help. Optional
+
+Example usage:
+ $0 --contractsdir=contracts --mainsol=MyContract.sol --outputsol=flattened/MyContracts_flattened.sol --verbose
+
+Installation:
+ Download solidityFlattener.pl from https://github.com/bokkypoobah/SolidityFlattener into /usr/local/bin
+ chmod 755 /usr/local/bin/solidityFlattener.pl
+
+Works on OS/X, Linux and Linux on Windows.
+
+Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018. The MIT Licence.
+
+Stopped\;
+
+my ($contractsdir, $remapdir, $mainsol, $outputsol, $help, $verbose);
+my %seen = ();
+
+GetOptions(
+ "contractsdir:s" => \$contractsdir,
+ "remapdir:s" => \$remapdir,
+ "mainsol:s" => \$mainsol,
+ "outputsol:s" => \$outputsol,
+ "verbose" => \$verbose,
+ "help" => \$help)
+or die $helptext;
+
+die $helptext
+ if defined $help;
+
+die $helptext
+ unless defined $mainsol;
+
+$contractsdir = $DEFAULTCONTRACTSDIR
+ unless defined $contractsdir;
+
+if (!defined $outputsol) {
+ $outputsol = $mainsol;
+ $outputsol =~ s/\.sol/_flattened\.sol/g;
+}
+
+if (defined $verbose) {
+ printf "contractsdir: %s\n", $contractsdir;
+ printf "remapdir : %s\n", defined $remapdir ? $remapdir : "(no remapping)";
+ printf "mainsol : %s\n", $mainsol;
+ printf "outputsol : %s\n", $outputsol
+}
+
+open OUTPUT, ">$outputsol"
+ or die "Cannot open $outputsol for writing. Stopped";
+
+processSol(catfile($contractsdir, $mainsol), 0);
+
+close OUTPUT
+ or die "Cannot close $outputsol. Stopped";
+
+exit;
+
+
+# ------------------------------------------------------------------------------
+# Process Solidity file
+# ------------------------------------------------------------------------------
+sub processSol {
+ my ($sol, $level) = @_;
+ if (defined $remapdir) {
+ my ($splitfrom, $splitto) = split /=/, $remapdir;
+ # printf "%sSplit %s: %s => %s\n", " " x $level, $remapdir, $splitfrom, $splitto
+ # if defined $verbose;
+ if ($sol =~ /$splitfrom/) {
+ printf "%sRemapping %s\n", " " x $level, $sol
+ if defined $verbose;
+ $sol =~ s!$splitfrom!$splitto!;
+ printf "%s to %s\n", " " x $level, $sol
+ if defined $verbose;
+ }
+ }
+ my $dir = dirname($sol);
+ my $file = basename($sol);
+ $seen{$file} = 1;
+ printf "%sProcessing %s\n", " " x $level, $sol
+ if defined $verbose;
+
+ open INPUT, "<$sol"
+ or die "Cannot open $sol for reading. Stopped";
+ my @lines = ;
+ close INPUT
+ or die "Cannot close $sol. Stopped";
+
+ for my $line (@lines) {
+ chomp $line;
+ if ($line =~ /^import/) {
+ my $importfile = $line;
+ $importfile =~ s/import [\"\']//;
+ $importfile =~ s/[\"\'];.*$//;
+ $file = basename($importfile);
+ if ($seen{$file}) {
+ printf "%s Already Imported %s\n", " " x $level, catfile($dir, $importfile)
+ if defined $verbose;
+ } else {
+ printf "%s Importing %s\n", " " x $level, catfile($dir, $importfile)
+ if defined $verbose;
+ processSol(catfile($dir, $importfile), $level + 1)
+ }
+ } else {
+ if ($level == 0 || !($line =~ /^pragma/)) {
+ printf OUTPUT "%s\n", $line;
+ }
+ }
+ }
+}
diff --git a/test/01_test1.sh b/test/01_test1.sh
index 1f46c56..b0c7508 100755
--- a/test/01_test1.sh
+++ b/test/01_test1.sh
@@ -7,20 +7,10 @@
MODE=${1:-full}
-GETHATTACHPOINT=`grep ^IPCFILE= settings.txt | sed "s/^.*=//"`
-PASSWORD=`grep ^PASSWORD= settings.txt | sed "s/^.*=//"`
-
-SOURCEDIR=`grep ^SOURCEDIR= settings.txt | sed "s/^.*=//"`
-
-DATETIMELIBSOL=`grep ^DATETIMELIBSOL= settings.txt | sed "s/^.*=//"`
-DATETIMELIBJS=`grep ^DATETIMELIBJS= settings.txt | sed "s/^.*=//"`
-TESTDATETIMESOL=`grep ^TESTDATETIMESOL= settings.txt | sed "s/^.*=//"`
-TESTDATETIMEJS=`grep ^TESTDATETIMEJS= settings.txt | sed "s/^.*=//"`
-
-DEPLOYMENTDATA=`grep ^DEPLOYMENTDATA= settings.txt | sed "s/^.*=//"`
-
-TEST1OUTPUT=`grep ^TEST1OUTPUT= settings.txt | sed "s/^.*=//"`
-TEST1RESULTS=`grep ^TEST1RESULTS= settings.txt | sed "s/^.*=//"`
+source settings
+echo "---------- Settings ----------" | tee $TEST1OUTPUT
+cat ./settings | tee -a $TEST1OUTPUT
+echo "" | tee -a $TEST1OUTPUT
CURRENTTIME=`date +%s`
CURRENTTIMES=`perl -le "print scalar localtime $CURRENTTIME"`
@@ -60,10 +50,12 @@ DIFFS1=`diff $SOURCEDIR/$TESTDATETIMESOL $TESTDATETIMESOL`
echo "--- Differences $SOURCEDIR/$TESTDATETIMESOL $TESTDATETIMESOL ---" | tee -a $TEST1OUTPUT
echo "$DIFFS1" | tee -a $TEST1OUTPUT
-solc_0.4.24 --version | tee -a $TEST1OUTPUT
+solc_0.5.4 --version | tee -a $TEST1OUTPUT
+
+echo "var dateTimeLibOutput=`solc_0.5.4 --optimize --pretty-json --combined-json abi,bin,interface $DATETIMELIBSOL`;" > $DATETIMELIBJS
+echo "var testDateTimeOutput=`solc_0.5.4 --optimize --pretty-json --combined-json abi,bin,interface $TESTDATETIMESOL`;" > $TESTDATETIMEJS
+../scripts/solidityFlattener.pl --contractsdir=../contracts --mainsol=$TESTDATETIMESOL --outputsol=$TESTDATETIMEFLATTENED --verbose | tee -a $TEST1OUTPUT
-echo "var dateTimeLibOutput=`solc_0.4.24 --optimize --pretty-json --combined-json abi,bin,interface $DATETIMELIBSOL`;" > $DATETIMELIBJS
-echo "var testDateTimeOutput=`solc_0.4.24 --optimize --pretty-json --combined-json abi,bin,interface $TESTDATETIMESOL`;" > $TESTDATETIMEJS
geth --verbosity 3 attach $GETHATTACHPOINT << EOF | tee -a $TEST1OUTPUT
loadScript("$DATETIMELIBJS");
@@ -607,4 +599,4 @@ EOF
grep "DATA: " $TEST1OUTPUT | sed "s/DATA: //" > $DEPLOYMENTDATA
cat $DEPLOYMENTDATA
grep "RESULT: " $TEST1OUTPUT | sed "s/RESULT: //" > $TEST1RESULTS
-cat $TEST1RESULTS
\ No newline at end of file
+cat $TEST1RESULTS
diff --git a/test/BokkyPooBahsDateTimeLibrary.js b/test/BokkyPooBahsDateTimeLibrary.js
index ba7c751..152fdfb 100644
--- a/test/BokkyPooBahsDateTimeLibrary.js
+++ b/test/BokkyPooBahsDateTimeLibrary.js
@@ -4,8 +4,8 @@ var dateTimeLibOutput={
"BokkyPooBahsDateTimeLibrary.sol:BokkyPooBahsDateTimeLibrary" :
{
"abi" : "[]",
- "bin" : "604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600080fd00a165627a7a723058205c45fb2dd4e9732b9992826e9cea7c31721fc9f9aad51866666339e91697def60029"
+ "bin" : "604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a72305820533aca9f692463073a88892cdcbf098b8bbc5960c260ebe5944be46b68523fc70029"
}
},
- "version" : "0.4.24+commit.e67f0147.Darwin.appleclang"
+ "version" : "0.5.4+commit.9549d8ff.Darwin.appleclang"
};
diff --git a/test/BokkyPooBahsDateTimeLibrary.sol b/test/BokkyPooBahsDateTimeLibrary.sol
index 2823f99..01e4375 100644
--- a/test/BokkyPooBahsDateTimeLibrary.sol
+++ b/test/BokkyPooBahsDateTimeLibrary.sol
@@ -1,7 +1,7 @@
-pragma solidity ^0.4.24;
+pragma solidity ^0.5.0;
// ----------------------------------------------------------------------------
-// BokkyPooBah's DateTime Library v1.00
+// BokkyPooBah's DateTime Library v1.01
//
// A gas-efficient Solidity date and time library
//
@@ -22,10 +22,7 @@ pragma solidity ^0.4.24;
// dayOfWeek | 1 ... 7 | 1 = Monday, ..., 7 = Sunday
//
//
-// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018.
-//
-// GNU Lesser General Public License 3.0
-// https://www.gnu.org/licenses/lgpl-3.0.en.html
+// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.
// ----------------------------------------------------------------------------
library BokkyPooBahsDateTimeLibrary {
@@ -336,4 +333,4 @@ library BokkyPooBahsDateTimeLibrary {
require(fromTimestamp <= toTimestamp);
_seconds = toTimestamp - fromTimestamp;
}
-}
\ No newline at end of file
+}
diff --git a/test/TestDateTime.js b/test/TestDateTime.js
index 95f6cc1..c413ce1 100644
--- a/test/TestDateTime.js
+++ b/test/TestDateTime.js
@@ -4,13 +4,13 @@ var testDateTimeOutput={
"BokkyPooBahsDateTimeLibrary.sol:BokkyPooBahsDateTimeLibrary" :
{
"abi" : "[]",
- "bin" : "604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f30073000000000000000000000000000000000000000030146080604052600080fd00a165627a7a723058205c45fb2dd4e9732b9992826e9cea7c31721fc9f9aad51866666339e91697def60029"
+ "bin" : "604c602c600b82828239805160001a60731460008114601c57601e565bfe5b5030600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea165627a7a72305820533aca9f692463073a88892cdcbf098b8bbc5960c260ebe5944be46b68523fc70029"
},
"TestDateTime.sol:TestDateTime" :
{
"abi" : "[{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_hours\",\"type\":\"uint256\"}],\"name\":\"subHours\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"fromTimestamp\",\"type\":\"uint256\"},{\"name\":\"toTimestamp\",\"type\":\"uint256\"}],\"name\":\"diffMinutes\",\"outputs\":[{\"name\":\"_minutes\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"getDaysInMonth\",\"outputs\":[{\"name\":\"daysInMonth\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nextYear\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"year\",\"type\":\"uint256\"},{\"name\":\"month\",\"type\":\"uint256\"},{\"name\":\"day\",\"type\":\"uint256\"}],\"name\":\"isValidDate\",\"outputs\":[{\"name\":\"valid\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"year\",\"type\":\"uint256\"},{\"name\":\"month\",\"type\":\"uint256\"},{\"name\":\"day\",\"type\":\"uint256\"}],\"name\":\"timestampFromDate\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"getDayOfWeek\",\"outputs\":[{\"name\":\"dayOfWeek\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"fromTimestamp\",\"type\":\"uint256\"},{\"name\":\"toTimestamp\",\"type\":\"uint256\"}],\"name\":\"diffHours\",\"outputs\":[{\"name\":\"_hours\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"year\",\"type\":\"uint256\"},{\"name\":\"month\",\"type\":\"uint256\"},{\"name\":\"day\",\"type\":\"uint256\"},{\"name\":\"hour\",\"type\":\"uint256\"},{\"name\":\"minute\",\"type\":\"uint256\"},{\"name\":\"second\",\"type\":\"uint256\"}],\"name\":\"isValidDateTime\",\"outputs\":[{\"name\":\"valid\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"getHour\",\"outputs\":[{\"name\":\"hour\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"year\",\"type\":\"uint256\"},{\"name\":\"month\",\"type\":\"uint256\"}],\"name\":\"_getDaysInMonth\",\"outputs\":[{\"name\":\"daysInMonth\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_months\",\"type\":\"uint256\"}],\"name\":\"addMonths\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"isWeekEnd\",\"outputs\":[{\"name\":\"weekEnd\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_years\",\"type\":\"uint256\"}],\"name\":\"addYears\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_years\",\"type\":\"uint256\"}],\"name\":\"subYears\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_hours\",\"type\":\"uint256\"}],\"name\":\"addHours\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"year\",\"type\":\"uint256\"},{\"name\":\"month\",\"type\":\"uint256\"},{\"name\":\"day\",\"type\":\"uint256\"},{\"name\":\"hour\",\"type\":\"uint256\"},{\"name\":\"minute\",\"type\":\"uint256\"},{\"name\":\"second\",\"type\":\"uint256\"}],\"name\":\"timestampFromDateTime\",\"outputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"fromTimestamp\",\"type\":\"uint256\"},{\"name\":\"toTimestamp\",\"type\":\"uint256\"}],\"name\":\"diffSeconds\",\"outputs\":[{\"name\":\"_seconds\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"getDay\",\"outputs\":[{\"name\":\"day\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_days\",\"type\":\"uint256\"}],\"name\":\"addDays\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"fromTimestamp\",\"type\":\"uint256\"},{\"name\":\"toTimestamp\",\"type\":\"uint256\"}],\"name\":\"diffMonths\",\"outputs\":[{\"name\":\"_months\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_minutes\",\"type\":\"uint256\"}],\"name\":\"addMinutes\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"getSecond\",\"outputs\":[{\"name\":\"second\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_seconds\",\"type\":\"uint256\"}],\"name\":\"addSeconds\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"getYear\",\"outputs\":[{\"name\":\"year\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_minutes\",\"type\":\"uint256\"}],\"name\":\"subMinutes\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"getMonth\",\"outputs\":[{\"name\":\"month\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_months\",\"type\":\"uint256\"}],\"name\":\"subMonths\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"year\",\"type\":\"uint256\"}],\"name\":\"_isLeapYear\",\"outputs\":[{\"name\":\"leapYear\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"isLeapYear\",\"outputs\":[{\"name\":\"leapYear\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_days\",\"type\":\"uint256\"}],\"name\":\"subDays\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"fromTimestamp\",\"type\":\"uint256\"},{\"name\":\"toTimestamp\",\"type\":\"uint256\"}],\"name\":\"diffDays\",\"outputs\":[{\"name\":\"_days\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"isWeekDay\",\"outputs\":[{\"name\":\"weekDay\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"timestampToDate\",\"outputs\":[{\"name\":\"year\",\"type\":\"uint256\"},{\"name\":\"month\",\"type\":\"uint256\"},{\"name\":\"day\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"timestampToDateTime\",\"outputs\":[{\"name\":\"year\",\"type\":\"uint256\"},{\"name\":\"month\",\"type\":\"uint256\"},{\"name\":\"day\",\"type\":\"uint256\"},{\"name\":\"hour\",\"type\":\"uint256\"},{\"name\":\"minute\",\"type\":\"uint256\"},{\"name\":\"second\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"},{\"name\":\"_seconds\",\"type\":\"uint256\"}],\"name\":\"subSeconds\",\"outputs\":[{\"name\":\"newTimestamp\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"test\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"timestamp\",\"type\":\"uint256\"}],\"name\":\"getMinute\",\"outputs\":[{\"name\":\"minute\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"fromTimestamp\",\"type\":\"uint256\"},{\"name\":\"toTimestamp\",\"type\":\"uint256\"}],\"name\":\"diffYears\",\"outputs\":[{\"name\":\"_years\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}]",
- "bin" : "608060405234801561001057600080fd5b50610fa5806100206000396000f3006080604052600436106101e15763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166250155381146101e657806302e98e0d1461021357806310848ddf1461022e578063146bea7b1461024657806314b2d6dc1461025b5780631f4f77b21461028d57806322f8a2b8146102ab5780632af123b8146102c35780633293d007146102de5780633e239e1a146103055780633f9e0eb71461031d5780634355644d146103385780634371c46514610353578063442b8c791461036b578063444fda82146103865780634b321502146103a15780635e05bd6d146103bc57806362fb9697146103e357806365c72840146103fe5780637217523c146104165780637be341091461043157806389a3a00d1461044c5780638aa001fc146104675780638d4a2d391461047f57806392d663131461049a5780639e524caa146104b2578063a324ad24146104cd578063ad203bd4146104e5578063b05eb08d14610500578063b8d16dbc14610518578063c7b6fd6a14610530578063c9d346221461054b578063d6582d0d14610566578063de5101af1461057e578063ea1c1690146105b4578063f615ed54146105ff578063f8a8fd6d1461061a578063fa93f88314610631578063ff2258cb14610649575b600080fd5b3480156101f257600080fd5b50610201600435602435610664565b60408051918252519081900360200190f35b34801561021f57600080fd5b50610201600435602435610677565b34801561023a57600080fd5b50610201600435610683565b34801561025257600080fd5b50610201610694565b34801561026757600080fd5b5061027960043560243560443561069a565b604080519115158252519081900360200190f35b34801561029957600080fd5b506102016004356024356044356106af565b3480156102b757600080fd5b506102016004356106bc565b3480156102cf57600080fd5b506102016004356024356106c7565b3480156102ea57600080fd5b5061027960043560243560443560643560843560a4356106d3565b34801561031157600080fd5b506102016004356106ee565b34801561032957600080fd5b506102016004356024356106f9565b34801561034457600080fd5b50610201600435602435610705565b34801561035f57600080fd5b50610279600435610711565b34801561037757600080fd5b5061020160043560243561071c565b34801561039257600080fd5b50610201600435602435610728565b3480156103ad57600080fd5b50610201600435602435610734565b3480156103c857600080fd5b5061020160043560243560443560643560843560a435610740565b3480156103ef57600080fd5b5061020160043560243561075a565b34801561040a57600080fd5b50610201600435610766565b34801561042257600080fd5b50610201600435602435610771565b34801561043d57600080fd5b5061020160043560243561077d565b34801561045857600080fd5b50610201600435602435610789565b34801561047357600080fd5b50610201600435610795565b34801561048b57600080fd5b506102016004356024356107a0565b3480156104a657600080fd5b506102016004356107ac565b3480156104be57600080fd5b506102016004356024356107b7565b3480156104d957600080fd5b506102016004356107c3565b3480156104f157600080fd5b506102016004356024356107ce565b34801561050c57600080fd5b506102796004356107da565b34801561052457600080fd5b506102796004356107e5565b34801561053c57600080fd5b506102016004356024356107f0565b34801561055757600080fd5b506102016004356024356107fc565b34801561057257600080fd5b50610279600435610808565b34801561058a57600080fd5b50610596600435610813565b60408051938452602084019290925282820152519081900360600190f35b3480156105c057600080fd5b506105cc60043561082e565b604080519687526020870195909552858501939093526060850191909152608084015260a0830152519081900360c00190f35b34801561060b57600080fd5b50610201600435602435610854565b34801561062657600080fd5b5061062f610860565b005b34801561063d57600080fd5b50610201600435610878565b34801561065557600080fd5b50610201600435602435610883565b6000610670838361088f565b9392505050565b600061067083836108a3565b600061068e826108c0565b92915050565b60005481565b60006106a78484846108ee565b949350505050565b60006106a7848484610943565b600061068e8261095d565b60006106708383610970565b60006106e387878787878761098a565b979650505050505050565b600061068e826109ca565b600061067083836109d8565b60006106708383610a5e565b600061068e82610ad4565b60006106708383610ae9565b60006106708383610b0f565b60006106708383610b6a565b60006106e3878787878787610b7e565b9695505050505050565b60006106708383610ba8565b600061068e82610bbc565b60006106708383610bcd565b60006106708383610be2565b60006106708383610c36565b600061068e82610c49565b60006106708383610c50565b600061068e82610c60565b60006106708383610c7c565b600061068e82610c8f565b60006106708383610caa565b600061068e82610d2b565b600061068e82610d50565b60006106708383610d72565b60006106708383610d87565b600061068e82610da2565b600080600061082184610db7565b9196909550909350915050565b60008060008060008061084087610dc8565b949c939b5091995097509550909350915050565b60006106708383610e09565b4261087281600163ffffffff610ae916565b60005550565b600061068e82610e19565b60006106708383610e28565b610e10810282038281111561068e57600080fd5b6000818311156108b257600080fd5b603c8383035b049392505050565b60008080806108d462015180865b04610e70565b919450925090506108e583836109d8565b95945050505050565b6000806107b285101580156109035750600084115b80156109105750600c8411155b1561093b5761091f85856109d8565b90506000831180156109315750808311155b1561093b57600191505b509392505050565b600062015180610954858585610f05565b02949350505050565b6007620151809091046003010660010190565b60008183111561097f57600080fd5b610e108383036108b8565b60006109978787876108ee565b15610750576018841080156109ac5750603c83105b80156109b85750603c82105b15610750575060019695505050505050565b610e10620151809091060490565b600081600114806109e95750816003145b806109f45750816005145b806109ff5750816007145b80610a0a5750816008145b80610a15575081600a145b80610a20575081600c145b15610a2d5750601f61068e565b60028214610a3d5750601e61068e565b610a4683610d2b565b610a5157601c610a54565b601d5b60ff169392505050565b600080808080610a7162015180886108ce565b600c91890160001901828104939093019650910660010193509150610a9684846109d8565b905080821115610aa4578091505b62015180870662015180610ab9868686610f05565b0201945086851015610aca57600080fd5b5050505092915050565b60006006610ae18361095d565b101592915050565b600080808080610afc62015180886108ce565b918801955093509150610a9684846109d8565b600080808080610b2262015180886108ce565b91889003955093509150610b3684846109d8565b905080821115610b44578091505b62015180870662015180610b59868686610f05565b0201945086851115610aca57600080fd5b610e10810282018281101561068e57600080fd5b600081603c8402610e10860262015180610b998b8b8b610f05565b02010101979650505050505050565b600081831115610bb757600080fd5b500390565b6000808061075062015180856108ce565b62015180810282018281101561068e57600080fd5b600080808080808087891115610bf757600080fd5b610c04620151808a6108ce565b91975095509350610c1862015180896108ce565b50600c97880297909102019590950393909303979650505050505050565b603c810282018281101561068e57600080fd5b603c900690565b8181018281101561068e57600080fd5b60008080610c7162015180856108ce565b509095945050505050565b603c810282038281111561068e57600080fd5b60008080610ca062015180856108ce565b5095945050505050565b60008080808080610cbe62015180896108ce565b91965094509250600c808602850188900360001901925082049450600c82066001019350610cec85856109d8565b905080831115610cfa578092505b62015180880662015180610d0f878787610f05565b0201955087861115610d2057600080fd5b505050505092915050565b600060048206158015610d4057506064820615155b8061068e57505061019090061590565b6000808080610d6262015180866108ce565b919450925090506108e583610d2b565b62015180810282038281111561068e57600080fd5b600081831115610d9657600080fd5b620151808383036108b8565b60006005610daf8361095d565b111592915050565b6000808061082162015180856108ce565b6000808080808080610ddd62015180896108ce565b919a9099919850610e10620151809092068281049850603c929006828104975091909106945092505050565b8082038281111561068e57600080fd5b6000610e108206603c816108b8565b600080808080808087891115610e3d57600080fd5b610e4a620151808a6108ce565b91975095509350610e5e62015180896108ce565b50509590950398975050505050505050565b60008080836226496581018280808062023ab1600486020593506004600362023ab1860201059094039362164b09610fa0600187010205925060046105b58402058503601f01945061098f85605002811515610ec857fe5b059150605061098f83020585039050600b820560301994909401606402929092018301996002600c90940290910392909201975095509350505050565b6000808080806107b2881015610f1a57600080fd5b50505050600460036064611324600c600d198801819005988901918201929092059290920283900561016f9782029096036001190196909602959095056105b56112c090960195909502059190910192909201036225bad619019190505600a165627a7a723058209c5448bf6edc8bf7ffa6755b7a9643d23d3a7b104dcf5d82fd1c79234115a03c0029"
+ "bin" : "608060405234801561001057600080fd5b50611117806100206000396000f3fe608060405234801561001057600080fd5b5060043610610259576000357c0100000000000000000000000000000000000000000000000000000000900480637217523c11610158578063b8d16dbc116100d5578063ea1c169011610099578063ea1c169014610721578063f615ed5414610771578063f8a8fd6d14610794578063fa93f8831461079e578063ff2258cb146107bb57610259565b8063b8d16dbc14610666578063c7b6fd6a14610683578063c9d34622146106a6578063d6582d0d146106c9578063de5101af146106e657610259565b806392d663131161011c57806392d66313146105c95780639e524caa146105e6578063a324ad2414610609578063ad203bd414610626578063b05eb08d1461064957610259565b80637217523c146105205780637be341091461054357806389a3a00d146105665780638aa001fc146105895780638d4a2d39146105a657610259565b80633e239e1a116101e6578063444fda82116101aa578063444fda821461045f5780634b321502146104825780635e05bd6d146104a557806362fb9697146104e057806365c728401461050357610259565b80633e239e1a146103bc5780633f9e0eb7146103d95780634355644d146103fc5780634371c4651461041f578063442b8c791461043c57610259565b806314b2d6dc1161022d57806314b2d6dc146102db5780631f4f77b21461031857806322f8a2b8146103415780632af123b81461035e5780633293d0071461038157610259565b80625015531461025e57806302e98e0d1461029357806310848ddf146102b6578063146bea7b146102d3575b600080fd5b6102816004803603604081101561027457600080fd5b50803590602001356107de565b60408051918252519081900360200190f35b610281600480360360408110156102a957600080fd5b50803590602001356107f1565b610281600480360360208110156102cc57600080fd5b50356107fd565b61028161080e565b610304600480360360608110156102f157600080fd5b5080359060208101359060400135610814565b604080519115158252519081900360200190f35b6102816004803603606081101561032e57600080fd5b5080359060208101359060400135610829565b6102816004803603602081101561035757600080fd5b5035610836565b6102816004803603604081101561037457600080fd5b5080359060200135610841565b610304600480360360c081101561039757600080fd5b5080359060208101359060408101359060608101359060808101359060a0013561084d565b610281600480360360208110156103d257600080fd5b5035610868565b610281600480360360408110156103ef57600080fd5b5080359060200135610873565b6102816004803603604081101561041257600080fd5b508035906020013561087f565b6103046004803603602081101561043557600080fd5b503561088b565b6102816004803603604081101561045257600080fd5b5080359060200135610896565b6102816004803603604081101561047557600080fd5b50803590602001356108a2565b6102816004803603604081101561049857600080fd5b50803590602001356108ae565b610281600480360360c08110156104bb57600080fd5b5080359060208101359060408101359060608101359060808101359060a001356108ba565b610281600480360360408110156104f657600080fd5b50803590602001356108d4565b6102816004803603602081101561051957600080fd5b50356108e0565b6102816004803603604081101561053657600080fd5b50803590602001356108eb565b6102816004803603604081101561055957600080fd5b50803590602001356108f7565b6102816004803603604081101561057c57600080fd5b5080359060200135610903565b6102816004803603602081101561059f57600080fd5b503561090f565b610281600480360360408110156105bc57600080fd5b508035906020013561091a565b610281600480360360208110156105df57600080fd5b5035610926565b610281600480360360408110156105fc57600080fd5b5080359060200135610931565b6102816004803603602081101561061f57600080fd5b503561093d565b6102816004803603604081101561063c57600080fd5b5080359060200135610948565b6103046004803603602081101561065f57600080fd5b5035610954565b6103046004803603602081101561067c57600080fd5b503561095f565b6102816004803603604081101561069957600080fd5b508035906020013561096a565b610281600480360360408110156106bc57600080fd5b5080359060200135610976565b610304600480360360208110156106df57600080fd5b5035610982565b610703600480360360208110156106fc57600080fd5b503561098d565b60408051938452602084019290925282820152519081900360600190f35b61073e6004803603602081101561073757600080fd5b50356109a8565b604080519687526020870195909552858501939093526060850191909152608084015260a0830152519081900360c00190f35b6102816004803603604081101561078757600080fd5b50803590602001356109ce565b61079c6109da565b005b610281600480360360208110156107b457600080fd5b50356109f2565b610281600480360360408110156107d157600080fd5b50803590602001356109fd565b60006107ea8383610a09565b9392505050565b60006107ea8383610a1d565b600061080882610a3a565b92915050565b60005481565b6000610821848484610a68565b949350505050565b6000610821848484610abe565b600061080882610ad8565b60006107ea8383610aeb565b600061085d878787878787610b05565b979650505050505050565b600061080882610b45565b60006107ea8383610b53565b60006107ea8383610bd9565b600061080882610c50565b60006107ea8383610c65565b60006107ea8383610c8c565b60006107ea8383610ce8565b600061085d878787878787610cfc565b9695505050505050565b60006107ea8383610d26565b600061080882610d3a565b60006107ea8383610d4b565b60006107ea8383610d60565b60006107ea8383610db5565b600061080882610dc8565b60006107ea8383610dcf565b600061080882610ddf565b60006107ea8383610dfb565b600061080882610e0e565b60006107ea8383610e29565b600061080882610ea9565b600061080882610ece565b60006107ea8383610ef0565b60006107ea8383610f05565b600061080882610f20565b600080600061099b84610f35565b9196909550909350915050565b6000806000806000806109ba87610f46565b949c939b5091995097509550909350915050565b60006107ea8383610f85565b426109ec81600163ffffffff610c6516565b60005550565b600061080882610f95565b60006107ea8383610fa4565b610e10810282038281111561080857600080fd5b600081831115610a2c57600080fd5b603c8383035b049392505050565b6000808080610a4e62015180865b04610fed565b91945092509050610a5f8383610b53565b95945050505050565b60006107b28410158015610a7c5750600083115b8015610a895750600c8311155b156107ea576000610a9a8585610b53565b9050600083118015610aac5750808311155b15610ab657600191505b509392505050565b600062015180610acf858585611085565b02949350505050565b6007620151809091046003010660010190565b600081831115610afa57600080fd5b610e10838303610a32565b6000610b12878787610a68565b156108ca57601884108015610b275750603c83105b8015610b335750603c82105b156108ca575060019695505050505050565b610e10620151809091060490565b60008160011480610b645750816003145b80610b6f5750816005145b80610b7a5750816007145b80610b855750816008145b80610b90575081600a145b80610b9b575081600c145b15610ba85750601f610808565b60028214610bb85750601e610808565b610bc183610ea9565b610bcc57601c610bcf565b601d5b60ff169392505050565b6000808080610beb6201518087610a48565b600c918801600019018281049390930195509106600101925090506000610c128484610b53565b905080821115610c20578091505b62015180870662015180610c35868686611085565b0201945086851015610c4657600080fd5b5050505092915050565b60006006610c5d83610ad8565b101592915050565b6000808080610c776201518087610a48565b9187019450925090506000610c128484610b53565b6000808080610c9e6201518087610a48565b918790039450925090506000610cb48484610b53565b905080821115610cc2578091505b62015180870662015180610cd7868686611085565b0201945086851115610c4657600080fd5b610e10810282018281101561080857600080fd5b600081603c8402610e10860262015180610d178b8b8b611085565b02010101979650505050505050565b600081831115610d3557600080fd5b500390565b600080806108ca6201518085610a48565b62015180810282018281101561080857600080fd5b600081831115610d6f57600080fd5b60008080808080610d83620151808a610a48565b91975095509350610d976201518089610a48565b50600c97880297909102019590950393909303979650505050505050565b603c810282018281101561080857600080fd5b603c900690565b8181018281101561080857600080fd5b60008080610df06201518085610a48565b509095945050505050565b603c810282038281111561080857600080fd5b60008080610e1f6201518085610a48565b5095945050505050565b6000808080610e3b6201518087610a48565b91945092509050600c8084028301869003600019019081049350600c810660010192506000610e6a8585610b53565b905080831115610e78578092505b62015180880662015180610e8d878787611085565b0201955087861115610e9e57600080fd5b505050505092915050565b600060048206158015610ebe57506064820615155b8061080857505061019090061590565b6000808080610ee06201518086610a48565b91945092509050610a5f83610ea9565b62015180810282038281111561080857600080fd5b600081831115610f1457600080fd5b62015180838303610a32565b60006005610f2d83610ad8565b111592915050565b6000808061099b6201518085610a48565b60008080808080610f5a6201518088610a48565b91999098919750610e10620151809092068281049750603c9290068281049650919091069350915050565b8082038281111561080857600080fd5b6000610e108206603c81610a32565b600081831115610fb357600080fd5b60008080808080610fc7620151808a610a48565b91975095509350610fdb6201518089610a48565b50509590950398975050505050505050565b60008080836226496581018262023ab1600483020590506004600362023ab18302010590910390600062164b09610fa0600185010205905060046105b58202058303601f019250600061098f8460500281151561104657fe5b0590506000605061098f83020585039050600b820560301994909401606402929092018301996002600c90940290910392909201975095509350505050565b60006107b284101561109657600080fd5b506225bad61960046064600c600d1986018190059687016113248101929092056003028390056112c09092016105b502929092059093016001199582029094039490940161016f02939093059190910103019056fea165627a7a72305820f4e316be3a3dba82235ea0c8e9054f9134e76229456fff16f1a71a36ae1907b40029"
}
},
- "version" : "0.4.24+commit.e67f0147.Darwin.appleclang"
+ "version" : "0.5.4+commit.9549d8ff.Darwin.appleclang"
};
diff --git a/test/TestDateTime.sol b/test/TestDateTime.sol
index 35bd201..071750a 100644
--- a/test/TestDateTime.sol
+++ b/test/TestDateTime.sol
@@ -1,4 +1,4 @@
-pragma solidity ^0.4.23;
+pragma solidity ^0.5.0;
import "BokkyPooBahsDateTimeLibrary.sol";
@@ -7,10 +7,7 @@ import "BokkyPooBahsDateTimeLibrary.sol";
//
// https://github.com/bokkypoobah/BokkyPooBahsDateTimeLibrary
//
-// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018.
-//
-// GNU Lesser General Public License 3.0
-// https://www.gnu.org/licenses/lgpl-3.0.en.html
+// Enjoy. (c) BokkyPooBah / Bok Consulting Pty Ltd 2018-2019. The MIT Licence.
// ----------------------------------------------------------------------------
contract TestDateTime {
@@ -141,4 +138,4 @@ contract TestDateTime {
function diffSeconds(uint fromTimestamp, uint toTimestamp) public pure returns (uint _seconds) {
_seconds = BokkyPooBahsDateTimeLibrary.diffSeconds(fromTimestamp, toTimestamp);
}
-}
\ No newline at end of file
+}
diff --git a/test/settings.txt b/test/settings
similarity index 81%
rename from test/settings.txt
rename to test/settings
index 20272f4..2ce4bf8 100644
--- a/test/settings.txt
+++ b/test/settings
@@ -1,4 +1,4 @@
-IPCFILE=ipc:./testchain/geth.ipc
+GETHATTACHPOINT=ipc:./testchain/geth.ipc
PASSWORD=
SOURCEDIR=../contracts
@@ -7,6 +7,7 @@ DATETIMELIBSOL=BokkyPooBahsDateTimeLibrary.sol
DATETIMELIBJS=BokkyPooBahsDateTimeLibrary.js
TESTDATETIMESOL=TestDateTime.sol
TESTDATETIMEJS=TestDateTime.js
+TESTDATETIMEFLATTENED=../flattened/TestDateTime_flattened.sol
DEPLOYMENTDATA=deploymentData.js
diff --git a/test/test1output.txt b/test/test1output.txt
index d36379e..ad776ac 100644
--- a/test/test1output.txt
+++ b/test/test1output.txt
@@ -9,20 +9,27 @@ TESTDATETIMEJS = 'TestDateTime.js'
DEPLOYMENTDATA = 'deploymentData.js'
TEST1OUTPUT = 'test1output.txt'
TEST1RESULTS = 'test1results.txt'
-CURRENTTIME = '1535866280' 'Sun Sep 2 15:31:20 2018'
-START_DATE = '1535866325' 'Sun Sep 2 15:32:05 2018'
-END_DATE = '1535866400' 'Sun Sep 2 15:33:20 2018'
+CURRENTTIME = '1550076725' 'Thu Feb 14 03:52:05 2019'
+START_DATE = '1550076770' 'Thu Feb 14 03:52:50 2019'
+END_DATE = '1550076845' 'Thu Feb 14 03:54:05 2019'
--- Differences ../contracts/BokkyPooBahsDateTimeLibrary.sol BokkyPooBahsDateTimeLibrary.sol ---
--- Differences ../contracts/TestDateTime.sol TestDateTime.sol ---
solc, the solidity compiler commandline interface
-Version: 0.4.24+commit.e67f0147.Darwin.appleclang
+Version: 0.5.4+commit.9549d8ff.Darwin.appleclang
+contractsdir: ../contracts
+remapdir : (no remapping)
+mainsol : TestDateTime.sol
+outputsol : ../flattened/TestDateTime_flattened.sol
+Processing ../contracts/TestDateTime.sol
+ Importing ../contracts/BokkyPooBahsDateTimeLibrary.sol
+ Processing ../contracts/BokkyPooBahsDateTimeLibrary.sol
Welcome to the Geth JavaScript console!
-instance: Geth/v1.8.12-stable-37685930/darwin-amd64/go1.10.3
+instance: Geth/v1.8.22-stable-7fa3509e/darwin-amd64/go1.11.5
coinbase: 0xa00af22d07c87d96eeeb0ed583f8f6ac7812827e
-at block: 12 (Sun, 02 Sep 2018 15:31:21 AEST)
+at block: 3 (Thu, 14 Feb 2019 03:52:05 AEDT)
datadir: /Users/bok/Projects/BokkyPooBahsDateTimeLibrary/test/testchain
modules: admin:1.0 clique:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0
@@ -123,8 +130,8 @@ DATA: var dateTimeLibAbi=[];
DATA: var dateTimeLib=eth.contract(dateTimeLibAbi).at(dateTimeLibAddress);
RESULT: # Account EtherBalanceChange Token Name
RESULT: -- ------------------------------------------ --------------------------- ------------------------------ ---------------------------
-RESULT: 0 0xa00af22d07c87d96eeeb0ed583f8f6ac7812827e 0.001195968000000000 0.000000000000000000 Account #0 - Miner
-RESULT: 1 0xa11aae29840fbb5c86e6fd4cf809eba183aef433 -0.001195968000000000 0.000000000000000000 Account #1 - Contract Owner
+RESULT: 0 0xa00af22d07c87d96eeeb0ed583f8f6ac7812827e 0.001198016000000000 0.000000000000000000 Account #0 - Miner
+RESULT: 1 0xa11aae29840fbb5c86e6fd4cf809eba183aef433 -0.001198016000000000 0.000000000000000000 Account #1 - Contract Owner
RESULT: 2 0xa22ab8a9d641ce77e06d98b7d7065d324d3d6976 0.000000000000000000 0.000000000000000000 Account #2 - Alice
RESULT: 3 0xa33a6c312d9ad0e0f2e95541beed0cc081621fd0 0.000000000000000000 0.000000000000000000 Account #3 - Bob
RESULT: 4 0xa44a08d3f6933c69212114bb66e2df1813651844 0.000000000000000000 0.000000000000000000 Account #4 - Carol
@@ -145,7 +152,7 @@ undefined
RESULT: PASS Deploy DateTime Library
1
>
-RESULT: dateTimeLibTx status=0x1 Success gas=6000000 gasUsed=74748 costETH=0.001195968 costUSD=0.80812753728 @ ETH/USD=675.71 gasPrice=16 gwei block=30 txIx=0 txId=0x1026a34753653dc3bc4de670cff6a0e4d48ad754660378a0aae4e050d521d676 @ 1535866299 Sun, 02 Sep 2018 05:31:39 UTC
+RESULT: dateTimeLibTx status=0x1 Success gas=6000000 gasUsed=74876 costETH=0.001198016 costUSD=0.80951139136 @ ETH/USD=675.71 gasPrice=16 gwei block=28 txIx=0 txId=0xbc383517b572e939da6cc6501ec53df222b46cd082c6afb350b31adfefca7140 @ 1550076750 Wed, 13 Feb 2019 16:52:30 UTC
undefined
>
RESULT:
@@ -200,8 +207,8 @@ DATA: var testDateTime=eth.contract(testDateTimeAbi).at(testDateTimeAddress);
DATA: console.log("testDateTime=" + JSON.stringify(testDateTime));
RESULT: # Account EtherBalanceChange Token Name
RESULT: -- ------------------------------------------ --------------------------- ------------------------------ ---------------------------
-RESULT: 0 0xa00af22d07c87d96eeeb0ed583f8f6ac7812827e 0.019090528000000000 0.000000000000000000 Account #0 - Miner
-RESULT: 1 0xa11aae29840fbb5c86e6fd4cf809eba183aef433 -0.019090528000000000 0.000000000000000000 Account #1 - Contract Owner
+RESULT: 0 0xa00af22d07c87d96eeeb0ed583f8f6ac7812827e 0.020671056000000000 0.000000000000000000 Account #0 - Miner
+RESULT: 1 0xa11aae29840fbb5c86e6fd4cf809eba183aef433 -0.020671056000000000 0.000000000000000000 Account #1 - Contract Owner
RESULT: 2 0xa22ab8a9d641ce77e06d98b7d7065d324d3d6976 0.000000000000000000 0.000000000000000000 Account #2 - Alice
RESULT: 3 0xa33a6c312d9ad0e0f2e95541beed0cc081621fd0 0.000000000000000000 0.000000000000000000 Account #3 - Bob
RESULT: 4 0xa44a08d3f6933c69212114bb66e2df1813651844 0.000000000000000000 0.000000000000000000 Account #4 - Carol
@@ -223,7 +230,7 @@ undefined
RESULT: PASS Deploy TestDateTime Contract
1
>
-RESULT: testDateTimeAddress=0x0e946b999033257976aa5cbe0e3530618ca1582d status=0x1 Success gas=6000000 gasUsed=1118410 costETH=0.01789456 costUSD=12.0915331376 @ ETH/USD=675.71 gasPrice=16 gwei block=32 txIx=0 txId=0x611859ffcbe408de952cbf8227b548532e64472e61a50beb4c6efc84a131a5d4 @ 1535866301 Sun, 02 Sep 2018 05:31:41 UTC
+RESULT: testDateTimeAddress=0x0e946b999033257976aa5cbe0e3530618ca1582d status=0x1 Success gas=6000000 gasUsed=1217065 costETH=0.01947304 costUSD=13.1581278584 @ ETH/USD=675.71 gasPrice=16 gwei block=30 txIx=0 txId=0x58f294754e1d18602292281b62829bd034702a925f858240fe3b80a8409a91bf @ 1550076752 Wed, 13 Feb 2019 16:52:32 UTC
undefined
>
RESULT:
diff --git a/test/test1results.txt b/test/test1results.txt
index 05daff3..4bbf7e6 100644
--- a/test/test1results.txt
+++ b/test/test1results.txt
@@ -20,8 +20,8 @@
----- Deploy DateTime Library -----
# Account EtherBalanceChange Token Name
-- ------------------------------------------ --------------------------- ------------------------------ ---------------------------
- 0 0xa00af22d07c87d96eeeb0ed583f8f6ac7812827e 0.001195968000000000 0.000000000000000000 Account #0 - Miner
- 1 0xa11aae29840fbb5c86e6fd4cf809eba183aef433 -0.001195968000000000 0.000000000000000000 Account #1 - Contract Owner
+ 0 0xa00af22d07c87d96eeeb0ed583f8f6ac7812827e 0.001198016000000000 0.000000000000000000 Account #0 - Miner
+ 1 0xa11aae29840fbb5c86e6fd4cf809eba183aef433 -0.001198016000000000 0.000000000000000000 Account #1 - Contract Owner
2 0xa22ab8a9d641ce77e06d98b7d7065d324d3d6976 0.000000000000000000 0.000000000000000000 Account #2 - Alice
3 0xa33a6c312d9ad0e0f2e95541beed0cc081621fd0 0.000000000000000000 0.000000000000000000 Account #3 - Bob
4 0xa44a08d3f6933c69212114bb66e2df1813651844 0.000000000000000000 0.000000000000000000 Account #4 - Carol
@@ -38,13 +38,13 @@
-- ------------------------------------------ --------------------------- ------------------------------ ---------------------------
PASS Deploy DateTime Library
-dateTimeLibTx status=0x1 Success gas=6000000 gasUsed=74748 costETH=0.001195968 costUSD=0.80812753728 @ ETH/USD=675.71 gasPrice=16 gwei block=30 txIx=0 txId=0x1026a34753653dc3bc4de670cff6a0e4d48ad754660378a0aae4e050d521d676 @ 1535866299 Sun, 02 Sep 2018 05:31:39 UTC
+dateTimeLibTx status=0x1 Success gas=6000000 gasUsed=74876 costETH=0.001198016 costUSD=0.80951139136 @ ETH/USD=675.71 gasPrice=16 gwei block=28 txIx=0 txId=0xbc383517b572e939da6cc6501ec53df222b46cd082c6afb350b31adfefca7140 @ 1550076750 Wed, 13 Feb 2019 16:52:30 UTC
---------- Deploy TestDateTime Contract ----------
# Account EtherBalanceChange Token Name
-- ------------------------------------------ --------------------------- ------------------------------ ---------------------------
- 0 0xa00af22d07c87d96eeeb0ed583f8f6ac7812827e 0.019090528000000000 0.000000000000000000 Account #0 - Miner
- 1 0xa11aae29840fbb5c86e6fd4cf809eba183aef433 -0.019090528000000000 0.000000000000000000 Account #1 - Contract Owner
+ 0 0xa00af22d07c87d96eeeb0ed583f8f6ac7812827e 0.020671056000000000 0.000000000000000000 Account #0 - Miner
+ 1 0xa11aae29840fbb5c86e6fd4cf809eba183aef433 -0.020671056000000000 0.000000000000000000 Account #1 - Contract Owner
2 0xa22ab8a9d641ce77e06d98b7d7065d324d3d6976 0.000000000000000000 0.000000000000000000 Account #2 - Alice
3 0xa33a6c312d9ad0e0f2e95541beed0cc081621fd0 0.000000000000000000 0.000000000000000000 Account #3 - Bob
4 0xa44a08d3f6933c69212114bb66e2df1813651844 0.000000000000000000 0.000000000000000000 Account #4 - Carol
@@ -62,7 +62,7 @@ dateTimeLibTx status=0x1 Success gas=6000000 gasUsed=74748 costETH=0.001195968 c
-- ------------------------------------------ --------------------------- ------------------------------ ---------------------------
PASS Deploy TestDateTime Contract
-testDateTimeAddress=0x0e946b999033257976aa5cbe0e3530618ca1582d status=0x1 Success gas=6000000 gasUsed=1118410 costETH=0.01789456 costUSD=12.0915331376 @ ETH/USD=675.71 gasPrice=16 gwei block=32 txIx=0 txId=0x611859ffcbe408de952cbf8227b548532e64472e61a50beb4c6efc84a131a5d4 @ 1535866301 Sun, 02 Sep 2018 05:31:41 UTC
+testDateTimeAddress=0x0e946b999033257976aa5cbe0e3530618ca1582d status=0x1 Success gas=6000000 gasUsed=1217065 costETH=0.01947304 costUSD=13.1581278584 @ ETH/USD=675.71 gasPrice=16 gwei block=30 txIx=0 txId=0x58f294754e1d18602292281b62829bd034702a925f858240fe3b80a8409a91bf @ 1550076752 Wed, 13 Feb 2019 16:52:32 UTC
---------- Test isLeapYear ----------
PASS 2000,5,24,1,2,3 is a leap year