54 lines
1.6 KiB
Objective-C
54 lines
1.6 KiB
Objective-C
//
|
|
// EQNUtility.h
|
|
// Earthquake Network
|
|
//
|
|
// Refactored by Andrea Busi
|
|
// Copyright © 2020 Earthquake Network. All rights reserved.
|
|
//
|
|
|
|
#import <Foundation/Foundation.h>
|
|
#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 difference, in minutes
|
|
+ (NSString *)formattedStringForTimeDifference:(NSInteger)timeDifference;
|
|
|
|
/// Clear a given string from unwanted characters
|
|
/// @param messaggio Cleaned string
|
|
+ (NSString *)clearStringMessaggi:(NSString *)messaggio;
|
|
|
|
/// 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;
|
|
|
|
/// 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
|