@@ -56,7 +56,7 @@ library BokkyPooBahsDateTimeLibrary {
56
56
// - 3 * ((year + 4900 + (month - 14) / 12) / 100) / 4
57
57
// - offset
58
58
// ------------------------------------------------------------------------
59
- function _daysFromDate (uint year , uint month , uint day ) public pure returns (uint _days ) {
59
+ function _daysFromDate (uint year , uint month , uint day ) internal pure returns (uint _days ) {
60
60
int _year = int (year);
61
61
int _month = int (month);
62
62
int _day = int (day);
@@ -88,7 +88,7 @@ library BokkyPooBahsDateTimeLibrary {
88
88
// month = month + 2 - 12 * L
89
89
// year = 100 * (N - 49) + year + L
90
90
// ------------------------------------------------------------------------
91
- function _daysToDate (uint _days ) public pure returns (uint year , uint month , uint day ) {
91
+ function _daysToDate (uint _days ) internal pure returns (uint year , uint month , uint day ) {
92
92
int __days = int (_days);
93
93
94
94
int L = __days + 68569 + OFFSET19700101;
@@ -107,16 +107,16 @@ library BokkyPooBahsDateTimeLibrary {
107
107
day = uint (_day);
108
108
}
109
109
110
- function timestampFromDate (uint year , uint month , uint day ) public pure returns (uint timestamp ) {
110
+ function timestampFromDate (uint year , uint month , uint day ) internal pure returns (uint timestamp ) {
111
111
timestamp = _daysFromDate (year, month, day) * SECONDS_PER_DAY;
112
112
}
113
- function timestampFromDateTime (uint year , uint month , uint day , uint hour , uint minute , uint second ) public pure returns (uint timestamp ) {
113
+ function timestampFromDateTime (uint year , uint month , uint day , uint hour , uint minute , uint second ) internal pure returns (uint timestamp ) {
114
114
timestamp = _daysFromDate (year, month, day) * SECONDS_PER_DAY + hour * SECONDS_PER_HOUR + minute * SECONDS_PER_MINUTE + second;
115
115
}
116
- function timestampToDate (uint timestamp ) public pure returns (uint year , uint month , uint day ) {
116
+ function timestampToDate (uint timestamp ) internal pure returns (uint year , uint month , uint day ) {
117
117
(year, month, day) = _daysToDate (timestamp / SECONDS_PER_DAY);
118
118
}
119
- function timestampToDateTime (uint timestamp ) public pure returns (uint year , uint month , uint day , uint hour , uint minute , uint second ) {
119
+ function timestampToDateTime (uint timestamp ) internal pure returns (uint year , uint month , uint day , uint hour , uint minute , uint second ) {
120
120
(year, month, day) = _daysToDate (timestamp / SECONDS_PER_DAY);
121
121
uint secs = timestamp % SECONDS_PER_DAY;
122
122
hour = secs / SECONDS_PER_HOUR;
@@ -125,30 +125,30 @@ library BokkyPooBahsDateTimeLibrary {
125
125
second = secs % SECONDS_PER_MINUTE;
126
126
}
127
127
128
- function isLeapYear (uint timestamp ) public pure returns (bool leapYear ) {
128
+ function isLeapYear (uint timestamp ) internal pure returns (bool leapYear ) {
129
129
uint year;
130
130
uint month;
131
131
uint day;
132
132
(year, month, day) = _daysToDate (timestamp / SECONDS_PER_DAY);
133
133
leapYear = _isLeapYear (year);
134
134
}
135
- function _isLeapYear (uint year ) public pure returns (bool leapYear ) {
135
+ function _isLeapYear (uint year ) internal pure returns (bool leapYear ) {
136
136
leapYear = ((year % 4 == 0 ) && (year % 100 != 0 )) || (year % 400 == 0 );
137
137
}
138
- function isWeekDay (uint timestamp ) public pure returns (bool weekDay ) {
138
+ function isWeekDay (uint timestamp ) internal pure returns (bool weekDay ) {
139
139
weekDay = getDayOfWeek (timestamp) <= DOW_FRI;
140
140
}
141
- function isWeekEnd (uint timestamp ) public pure returns (bool weekEnd ) {
141
+ function isWeekEnd (uint timestamp ) internal pure returns (bool weekEnd ) {
142
142
weekEnd = getDayOfWeek (timestamp) >= DOW_SAT;
143
143
}
144
- function getDaysInMonth (uint timestamp ) public pure returns (uint daysInMonth ) {
144
+ function getDaysInMonth (uint timestamp ) internal pure returns (uint daysInMonth ) {
145
145
uint year;
146
146
uint month;
147
147
uint day;
148
148
(year, month, day) = _daysToDate (timestamp / SECONDS_PER_DAY);
149
149
daysInMonth = _getDaysInMonth (year, month);
150
150
}
151
- function _getDaysInMonth (uint year , uint month ) public pure returns (uint daysInMonth ) {
151
+ function _getDaysInMonth (uint year , uint month ) internal pure returns (uint daysInMonth ) {
152
152
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 ) {
153
153
daysInMonth = 31 ;
154
154
} else if (month != 2 ) {
@@ -158,39 +158,39 @@ library BokkyPooBahsDateTimeLibrary {
158
158
}
159
159
}
160
160
// 1 = Monday, 7 = Sunday
161
- function getDayOfWeek (uint timestamp ) public pure returns (uint dayOfWeek ) {
161
+ function getDayOfWeek (uint timestamp ) internal pure returns (uint dayOfWeek ) {
162
162
uint _days = timestamp / SECONDS_PER_DAY;
163
163
dayOfWeek = (_days + 3 ) % 7 + 1 ;
164
164
}
165
165
166
- function getYear (uint timestamp ) public pure returns (uint year ) {
166
+ function getYear (uint timestamp ) internal pure returns (uint year ) {
167
167
uint month;
168
168
uint day;
169
169
(year, month, day) = _daysToDate (timestamp / SECONDS_PER_DAY);
170
170
}
171
- function getMonth (uint timestamp ) public pure returns (uint month ) {
171
+ function getMonth (uint timestamp ) internal pure returns (uint month ) {
172
172
uint year;
173
173
uint day;
174
174
(year, month, day) = _daysToDate (timestamp / SECONDS_PER_DAY);
175
175
}
176
- function getDay (uint timestamp ) public pure returns (uint day ) {
176
+ function getDay (uint timestamp ) internal pure returns (uint day ) {
177
177
uint year;
178
178
uint month;
179
179
(year, month, day) = _daysToDate (timestamp / SECONDS_PER_DAY);
180
180
}
181
- function getHour (uint timestamp ) public pure returns (uint hour ) {
181
+ function getHour (uint timestamp ) internal pure returns (uint hour ) {
182
182
uint secs = timestamp % SECONDS_PER_DAY;
183
183
hour = secs / SECONDS_PER_HOUR;
184
184
}
185
- function getMinute (uint timestamp ) public pure returns (uint minute ) {
185
+ function getMinute (uint timestamp ) internal pure returns (uint minute ) {
186
186
uint secs = timestamp % SECONDS_PER_HOUR;
187
187
minute = secs / SECONDS_PER_MINUTE;
188
188
}
189
- function getSecond (uint timestamp ) public pure returns (uint second ) {
189
+ function getSecond (uint timestamp ) internal pure returns (uint second ) {
190
190
second = timestamp % SECONDS_PER_MINUTE;
191
191
}
192
192
193
- function addYears (uint timestamp , uint _years ) public pure returns (uint newTimestamp ) {
193
+ function addYears (uint timestamp , uint _years ) internal pure returns (uint newTimestamp ) {
194
194
uint year;
195
195
uint month;
196
196
uint day;
@@ -203,7 +203,7 @@ library BokkyPooBahsDateTimeLibrary {
203
203
newTimestamp = _daysFromDate (year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
204
204
require (newTimestamp >= timestamp);
205
205
}
206
- function addMonths (uint timestamp , uint _months ) public pure returns (uint newTimestamp ) {
206
+ function addMonths (uint timestamp , uint _months ) internal pure returns (uint newTimestamp ) {
207
207
uint year;
208
208
uint month;
209
209
uint day;
@@ -218,24 +218,24 @@ library BokkyPooBahsDateTimeLibrary {
218
218
newTimestamp = _daysFromDate (year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
219
219
require (newTimestamp >= timestamp);
220
220
}
221
- function addDays (uint timestamp , uint _days ) public pure returns (uint newTimestamp ) {
221
+ function addDays (uint timestamp , uint _days ) internal pure returns (uint newTimestamp ) {
222
222
newTimestamp = timestamp + _days * SECONDS_PER_DAY;
223
223
require (newTimestamp >= timestamp);
224
224
}
225
- function addHours (uint timestamp , uint _hours ) public pure returns (uint newTimestamp ) {
225
+ function addHours (uint timestamp , uint _hours ) internal pure returns (uint newTimestamp ) {
226
226
newTimestamp = timestamp + _hours * SECONDS_PER_HOUR;
227
227
require (newTimestamp >= timestamp);
228
228
}
229
- function addMinutes (uint timestamp , uint _minutes ) public pure returns (uint newTimestamp ) {
229
+ function addMinutes (uint timestamp , uint _minutes ) internal pure returns (uint newTimestamp ) {
230
230
newTimestamp = timestamp + _minutes * SECONDS_PER_MINUTE;
231
231
require (newTimestamp >= timestamp);
232
232
}
233
- function addSeconds (uint timestamp , uint _seconds ) public pure returns (uint newTimestamp ) {
233
+ function addSeconds (uint timestamp , uint _seconds ) internal pure returns (uint newTimestamp ) {
234
234
newTimestamp = timestamp + _seconds;
235
235
require (newTimestamp >= timestamp);
236
236
}
237
237
238
- function subYears (uint timestamp , uint _years ) public pure returns (uint newTimestamp ) {
238
+ function subYears (uint timestamp , uint _years ) internal pure returns (uint newTimestamp ) {
239
239
uint year;
240
240
uint month;
241
241
uint day;
@@ -248,7 +248,7 @@ library BokkyPooBahsDateTimeLibrary {
248
248
newTimestamp = _daysFromDate (year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
249
249
require (newTimestamp <= timestamp);
250
250
}
251
- function subMonths (uint timestamp , uint _months ) public pure returns (uint newTimestamp ) {
251
+ function subMonths (uint timestamp , uint _months ) internal pure returns (uint newTimestamp ) {
252
252
uint year;
253
253
uint month;
254
254
uint day;
@@ -263,24 +263,24 @@ library BokkyPooBahsDateTimeLibrary {
263
263
newTimestamp = _daysFromDate (year, month, day) * SECONDS_PER_DAY + timestamp % SECONDS_PER_DAY;
264
264
require (newTimestamp <= timestamp);
265
265
}
266
- function subDays (uint timestamp , uint _days ) public pure returns (uint newTimestamp ) {
266
+ function subDays (uint timestamp , uint _days ) internal pure returns (uint newTimestamp ) {
267
267
newTimestamp = timestamp - _days * SECONDS_PER_DAY;
268
268
require (newTimestamp <= timestamp);
269
269
}
270
- function subHours (uint timestamp , uint _hours ) public pure returns (uint newTimestamp ) {
270
+ function subHours (uint timestamp , uint _hours ) internal pure returns (uint newTimestamp ) {
271
271
newTimestamp = timestamp - _hours * SECONDS_PER_HOUR;
272
272
require (newTimestamp <= timestamp);
273
273
}
274
- function subMinutes (uint timestamp , uint _minutes ) public pure returns (uint newTimestamp ) {
274
+ function subMinutes (uint timestamp , uint _minutes ) internal pure returns (uint newTimestamp ) {
275
275
newTimestamp = timestamp - _minutes * SECONDS_PER_MINUTE;
276
276
require (newTimestamp <= timestamp);
277
277
}
278
- function subSeconds (uint timestamp , uint _seconds ) public pure returns (uint newTimestamp ) {
278
+ function subSeconds (uint timestamp , uint _seconds ) internal pure returns (uint newTimestamp ) {
279
279
newTimestamp = timestamp - _seconds;
280
280
require (newTimestamp <= timestamp);
281
281
}
282
282
283
- function diffYears (uint fromTimestamp , uint toTimestamp ) public pure returns (uint _years ) {
283
+ function diffYears (uint fromTimestamp , uint toTimestamp ) internal pure returns (uint _years ) {
284
284
require (fromTimestamp <= toTimestamp);
285
285
uint fromYear;
286
286
uint fromMonth;
@@ -292,7 +292,7 @@ library BokkyPooBahsDateTimeLibrary {
292
292
(toYear, toMonth, toDay) = _daysToDate (toTimestamp / SECONDS_PER_DAY);
293
293
_years = toYear - fromYear;
294
294
}
295
- function diffMonths (uint fromTimestamp , uint toTimestamp ) public pure returns (uint _months ) {
295
+ function diffMonths (uint fromTimestamp , uint toTimestamp ) internal pure returns (uint _months ) {
296
296
require (fromTimestamp <= toTimestamp);
297
297
uint fromYear;
298
298
uint fromMonth;
@@ -304,19 +304,19 @@ library BokkyPooBahsDateTimeLibrary {
304
304
(toYear, toMonth, toDay) = _daysToDate (toTimestamp / SECONDS_PER_DAY);
305
305
_months = toYear * 12 + toMonth - fromYear * 12 - fromMonth;
306
306
}
307
- function diffDays (uint fromTimestamp , uint toTimestamp ) public pure returns (uint _days ) {
307
+ function diffDays (uint fromTimestamp , uint toTimestamp ) internal pure returns (uint _days ) {
308
308
require (fromTimestamp <= toTimestamp);
309
309
_days = (toTimestamp - fromTimestamp) / SECONDS_PER_DAY;
310
310
}
311
- function diffHours (uint fromTimestamp , uint toTimestamp ) public pure returns (uint _hours ) {
311
+ function diffHours (uint fromTimestamp , uint toTimestamp ) internal pure returns (uint _hours ) {
312
312
require (fromTimestamp <= toTimestamp);
313
313
_hours = (toTimestamp - fromTimestamp) / SECONDS_PER_HOUR;
314
314
}
315
- function diffMinutes (uint fromTimestamp , uint toTimestamp ) public pure returns (uint _minutes ) {
315
+ function diffMinutes (uint fromTimestamp , uint toTimestamp ) internal pure returns (uint _minutes ) {
316
316
require (fromTimestamp <= toTimestamp);
317
317
_minutes = (toTimestamp - fromTimestamp) / SECONDS_PER_MINUTE;
318
318
}
319
- function diffSeconds (uint fromTimestamp , uint toTimestamp ) public pure returns (uint _seconds ) {
319
+ function diffSeconds (uint fromTimestamp , uint toTimestamp ) internal pure returns (uint _seconds ) {
320
320
require (fromTimestamp <= toTimestamp);
321
321
_seconds = toTimestamp - fromTimestamp;
322
322
}
0 commit comments