|
@@ -37,6 +37,53 @@ function scrollIntoView(element: HTMLDivElement, spot: {
|
|
|
parent.scrollTop = offsetY;
|
|
|
}
|
|
|
|
|
|
+export function convertAdobeDate(timestamp: string) {
|
|
|
+ if (timestamp) {
|
|
|
+ const year = parseInt(timestamp.substring(2, 6), 10)
|
|
|
+ const month = parseInt(timestamp.substring(6, 8), 10) - 1
|
|
|
+ const day = parseInt(timestamp.substring(8, 10), 10)
|
|
|
+ const hours = parseInt(timestamp.substring(10, 12), 10)
|
|
|
+ const minutes = parseInt(timestamp.substring(12, 14), 10)
|
|
|
+ const seconds = parseInt(timestamp.substring(14, 16), 10)
|
|
|
+ const date = new Date(Date.UTC(year, month, day, hours, minutes, seconds, 0))
|
|
|
+ const timezone = timestamp.substring(16)
|
|
|
+ if (7 === timezone.length) {
|
|
|
+ let offset: string | number = timezone.substring(0, 1);
|
|
|
+ if ("Z" !== offset) {
|
|
|
+ offset = "-" === offset ? 1 : -1;
|
|
|
+ const offsetMinutes = parseInt(timezone.substring(4, 6), 10);
|
|
|
+ date.setUTCHours(date.getUTCHours() + offset * parseInt(timezone.substring(1, 3), 10))
|
|
|
+ date.setUTCMinutes(date.getUTCMinutes() + offset * offsetMinutes)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return date
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function padZero(str: string) {
|
|
|
+ return 2 > str.length ? "0" + str : str
|
|
|
+}
|
|
|
+
|
|
|
+export function toAdobeDate(date: Date) {
|
|
|
+ if (!date) return
|
|
|
+ var timeString = "D:" + date.getFullYear().toString()
|
|
|
+ timeString += padZero((date.getMonth() + 1).toString())
|
|
|
+ timeString += padZero(date.getDate().toString())
|
|
|
+ timeString += padZero(date.getHours().toString())
|
|
|
+ timeString += padZero(date.getMinutes().toString())
|
|
|
+ timeString += padZero(date.getSeconds().toString())
|
|
|
+ let offset = date.getTimezoneOffset()
|
|
|
+ if (0 === offset) {
|
|
|
+ timeString += "Z00'00'"
|
|
|
+ } else {
|
|
|
+ 0 > offset ? (timeString += "+", offset *= -1) : timeString += "-"
|
|
|
+ var qa = offset % 60
|
|
|
+ timeString += padZero(parseInt((offset / 60).toString(), 10).toString()) + "'"
|
|
|
+ timeString += padZero(qa.toString()) + "'"
|
|
|
+ }
|
|
|
+ return timeString
|
|
|
+}
|
|
|
+
|
|
|
export {
|
|
|
scrollIntoView
|
|
|
}
|