| 164 | ) |
| 165 | |
| 166 | fun ExifInterface.fixExif(captureTime: Date) { |
| 167 | val millis = TimeZone.getDefault().getOffset(captureTime.time) |
| 168 | |
| 169 | val totalMins = (millis / (1000 * 60)) |
| 170 | |
| 171 | val hours = (totalMins / 60) |
| 172 | var hoursStrRep = hours.toString().padStart(2, '0') |
| 173 | |
| 174 | if (hours >= 0) |
| 175 | hoursStrRep = "+${hoursStrRep}" |
| 176 | |
| 177 | val mins = (totalMins % 60).toString().padEnd(2, '0') |
| 178 | |
| 179 | val offsetTime = "$hoursStrRep:$mins" |
| 180 | |
| 181 | setAttribute(ExifInterface.TAG_OFFSET_TIME, offsetTime) |
| 182 | setAttribute(ExifInterface.TAG_OFFSET_TIME_ORIGINAL, offsetTime) |
| 183 | // exifInterface.setAttribute(ExifInterface.TAG_OFFSET_TIME_DIGITIZED, offset_time) |
| 184 | |
| 185 | val nowStrRep = SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.US).format(captureTime) |
| 186 | |
| 187 | setAttribute(ExifInterface.TAG_DATETIME_ORIGINAL, nowStrRep) |
| 188 | setAttribute(ExifInterface.TAG_DATETIME, nowStrRep) |
| 189 | } |
| 190 | |
| 191 | fun ExifInterface.clearExif() { |
| 192 | for (exifTag in exifAttributes) { |