public static string DaysAgo(DateTime value) { if (_loader == null) { _loader = new LocalisationLoader(); } const int SECOND = 1; const int MINUTE = 60 * SECOND; const int HOUR = 60 * MINUTE; const int DAY = 24 * HOUR; const int WEEK = 7 * DAY; const int MONTH = 30 * DAY; DateTime theDate = value; int offset = TimeZoneInfo.Local.BaseUtcOffset.Hours; theDate = theDate.AddHours(offset); var ts = DateTime.Now.Subtract(theDate); double seconds = ts.TotalSeconds; // Less than one minute if (seconds < 1 * MINUTE) { return(string.Format(_loader.GetString("SecondsAgo"), ts.Seconds)); } if (seconds < 60 * MINUTE) { return(string.Format(_loader.GetString("MinutesAgo"), ts.Minutes)); } if (seconds < 120 * MINUTE) { return(string.Format(_loader.GetString("HoursAgo"), 1)); } if (seconds < 24 * HOUR) { return(string.Format(_loader.GetString("HoursAgo"), ts.Hours)); } if (seconds < 48 * HOUR) { return(string.Format(_loader.GetString("DaysAgo"), 1)); } if (seconds < 7 * DAY) { return(string.Format(_loader.GetString("DaysAgo"), ts.Days)); } if (seconds > 1 * WEEK) { var weeks = Convert.ToInt32(Math.Floor((double)ts.Days / 7)); return(string.Format(_loader.GetString("WeeksAgo"), weeks)); } return(string.Empty); }
public EditViewModel( INavigationService navigationService, ILocalisationLoader loader, IReaderHelper readerHelper, ReaderViewModel readerViewModel) { _navigationService = navigationService; _loader = loader; _readerHelper = readerHelper; _readerViewModel = readerViewModel; }
public object Convert(object value, Type targetType, object parameter, string language) { if (_loader == null) { _loader = SimpleIoc.Default.GetInstance <ILocalisationLoader>(); } var frequency = (UpdateFrequency)value; return(_loader.GetString(frequency.ToString())); }
private static string StringToDisplay(string originalString) { if (_loader == null) { _loader = SimpleIoc.Default.GetInstance <ILocalisationLoader>(); } if (string.IsNullOrEmpty(originalString)) { return(originalString); } var localisedString = _loader.GetString(originalString); return(string.IsNullOrEmpty(localisedString) ? originalString : localisedString); }
/// <summary> /// Initializes a new instance of the ReaderViewModel class. /// </summary> public ReaderViewModel( INavigationService navigationService, ISettingsService settingsService, IApplicationSettingsServiceHandler roamingSettings, ICacheService cacheService, IMessageBoxService messageBox, ILocalisationLoader loader, IReaderHelper readerHelper) { _navigationService = navigationService; _settingsService = settingsService; _roamingSettings = roamingSettings; _cacheService = cacheService; _messageBox = messageBox; _loader = loader; _readerHelper = readerHelper; }
public SettingsViewModel( INavigationService navigationService, ISettingsService settingsService, IAuthenticationService authenticationService, ITileService tileService, ILocalisationLoader loader, PocketViewModel pocketViewModel, ReadabilityViewModel readabilityViewModel) { _navigationService = navigationService; _settingsService = settingsService; _authenticationService = authenticationService; _tileService = tileService; _loader = loader; _pocketViewModel = pocketViewModel; _readabilityViewModel = readabilityViewModel; WordsAtATime = _settingsService.WordsAtATime; WordsPerMin = _settingsService.WordsPerMin; UseTransparentTile = _settingsService.UseTransparentTile; }
public AboutViewModel(ILocalisationLoader loader) { _loader = loader; _version = Package.Current.Id.Version; }