mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Transform into TypeScript
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||
|
||||
export async function getItem () {
|
||||
const getItem = async () => {
|
||||
try {
|
||||
const value = await AsyncStorage.getItem('@social.xmflsct.com')
|
||||
if (!value) {
|
||||
@ -15,10 +15,12 @@ export async function getItem () {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAllKeys () {
|
||||
const getAllKeys = async () => {
|
||||
try {
|
||||
return await AsyncStorage.getAllKeys()
|
||||
} catch (e) {
|
||||
console.error('Get all keys error')
|
||||
}
|
||||
}
|
||||
|
||||
export default { getItem, getAllKeys }
|
@ -1,7 +1,5 @@
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
export default function relativeTime (date) {
|
||||
var units = {
|
||||
const relativeTime = (date: string) => {
|
||||
let units = {
|
||||
year: 24 * 60 * 60 * 1000 * 365,
|
||||
month: (24 * 60 * 60 * 1000 * 365) / 12,
|
||||
day: 24 * 60 * 60 * 1000,
|
||||
@ -10,9 +8,9 @@ export default function relativeTime (date) {
|
||||
second: 1000
|
||||
}
|
||||
|
||||
var rtf = new Intl.RelativeTimeFormat('zh', { numeric: 'auto' })
|
||||
let rtf = new Intl.RelativeTimeFormat('zh', { numeric: 'auto' })
|
||||
|
||||
var elapsed = new Date(date) - new Date()
|
||||
let elapsed: number = new Date(date) - new Date()
|
||||
|
||||
// "Math.abs" accounts for both "past" & "future" scenarios
|
||||
for (var u in units)
|
||||
@ -20,6 +18,4 @@ export default function relativeTime (date) {
|
||||
return rtf.format(Math.round(elapsed / units[u]), u)
|
||||
}
|
||||
|
||||
relativeTime.propTypes = {
|
||||
date: PropTypes.string.isRequired
|
||||
}
|
||||
export default relativeTime
|
Reference in New Issue
Block a user