// // EQNUtility.h // Earthquake Network // // Refactored by Andrea Busi // Copyright © 2020 Earthquake Network. All rights reserved. // #import #import "Costanti.h" @class EQNGenericValue; @class EQNSegnalazione; NS_ASSUME_NONNULL_BEGIN @interface EQNUtility : NSObject /// Converts date received from web server into Date objects /// Time zone of the received date is Europe/Rome /// @param dateString String date received /// @return Date object + (nullable NSDate *)getDateFromString:(NSString *)dateString; /// Creates a string for a given time interval. /// Some examples: 1 hour ago, 25 minutes ago, 2 days ago /// @param timeDifference Time differnce + (NSString *)formattedStringForTimeDifference:(NSInteger)timeDifference; /// Clear a given string from unwanted characters /// @param messaggio Cleaned string + (NSString *)clearStringMessaggi:(NSString *)messaggio; /// Calculate time difference (in minutes) between the given date and the current timestamp /// @param date Difference (in minutes) + (NSInteger)getDifferenceMinute:(NSDate *)date; /// Store an array of custom objects to NSUserDefaults /// @param array Array to store /// @param keyName Key of NSUserDefault to use + (void)storeArray:(NSArray *)array toUserDefaultForKey:(NSString *)keyName; /// Retrieve a saved array of custom objects from NSUserDefaults. /// @param class Class of the objects inside the array /// @param keyName Key of NSUserDefault to retrieve + (nullable NSArray *)loadArrayOfClass:(Class)class fromUserDefaultsForKey:(NSString* )keyName; /// Store a dictionary to NSUserDefaults /// @param dictionary Dictionary to store /// @param keyName Key of NSUserDefault to use + (void)storeDictionary:(NSDictionary *)dictionary toUserDefaultForKey:(NSString *)keyName; /// Retrieve a saved dictionary from NSUserDefaults. /// @param keyName Key of NSUserDefault to retrieve + (nullable NSDictionary *)loadDictionaryFromUserDefaultsForKey:(NSString *)keyName; /// Calculate impact time from a received push notification /// @param info Payload of a received notification /// @return Impact time + (nullable NSDate *)calculateUserSeismicTimestampFromUserInfo:(NSDictionary *)info; @end NS_ASSUME_NONNULL_END