relative-date

How to convert NSDate in to relative format as “Today”,“Yesterday”,“a week ago”,“a month ago”,“a year ago”?

馋奶兔 提交于 2019-12-27 19:09:22
问题 I want to convert nsdate in to relative format like "Today","Yesterday","a week ago","a month ago","a year ago","date as it is" . I have written following method for it.. but some how its just printing as it is date.. can you please tell me what should be the problem? //Following is my function which converts the date into relative string +(NSString *)getDateDiffrence:(NSDate *)strDate{ NSDateFormatter *df = [[NSDateFormatter alloc] init]; df.timeStyle = NSDateFormatterMediumStyle; df

NSDateFormatter relative date formatting with custom format

荒凉一梦 提交于 2019-12-21 07:34:24
问题 So my intention is to put out dates that would look like the following: Today, August 28 Tomorrow, August 29 Friday, August 30 ...etc The issue is that it seems I can only get so close. When I setDoesRelativeDateFormatting:YES and setDateStyle to Full and setTimeStyle to None , it yields results like this: Today Tomorrow Friday, August 30, 2013 This yields the year and does not yield month and date for today and tomorrow. The other code I've tried is this: [NSDateFormatter

Force Android DateUtils.getRelativeDateTimeString() to ignore the device locale?

孤街浪徒 提交于 2019-12-12 08:23:12
问题 I've found using the android.text.format.DateUtils relative APIs that return values like "yesterday" or "2 hours ago" very nice - but my app does not support every language Android does. So, I default to English, but for every language I don't support, the relative string shows in the device's setting. For example, like: Last attempt: hace 11 minutos. I'd like to make the API call default to English for any languages I don't support. However, I don't see anywhere to set the Locale for the API

Updating the relative time in android

牧云@^-^@ 提交于 2019-12-11 05:34:39
问题 I am developing a Twitter client application. As with other twitter clients, I would like to display the relative time of tweet with respect to the current time. I am using a list view and a Simple adapter that binds to an arraylist which stores the tweet information. If I calculate the relative time and store a string, I will be just storing static data which will never get updated. How should I update this data?? Is there any way to do this? 回答1: You will have to incorporate on your adapter

How do I model “relative” time in a database?

谁都会走 提交于 2019-12-10 11:54:33
问题 Clarification: I am not trying to calculate friendly times (e.g., "8 seconds ago") by using a timestamp and the current time. I need to create a timeline of events in my data model, but where these events are only relative to each other. For example, I have events A, B, and C. They happen in order, so it may be that B occurs 20 seconds after A, and that C occurs 20 years after B. I don't care about the unit of time. For my purpose, there is no time, just relativity. I intend to model this

Relative time function in js for format YYYY-MM-DDTHH:MM:SS+0000

随声附和 提交于 2019-12-08 18:08:25
I was wondering if anyone knew how I could parse this type of date format: 2010-07-26T18:02:46+0000 into the relative time such as "30 seconds ago" I already have a function which does it for a similar but different time format: function relative_time(time_value, is_relative) { var values = time_value.split(" "), parsed_date = Date.parse(values[1] + " " + values[2] + ", " + values[5] + " " + values[3] + " UTC"), date = new Date(parsed_date), relative_to = new Date(), r = '', delta = parseInt((relative_to.getTime() - date.getTime()) / 1000); var seconds = { 'from' : { 'minutes' : function(v) {

Relative time function in js for format YYYY-MM-DDTHH:MM:SS+0000

≯℡__Kan透↙ 提交于 2019-12-08 06:54:53
问题 I was wondering if anyone knew how I could parse this type of date format: 2010-07-26T18:02:46+0000 into the relative time such as "30 seconds ago" I already have a function which does it for a similar but different time format: function relative_time(time_value, is_relative) { var values = time_value.split(" "), parsed_date = Date.parse(values[1] + " " + values[2] + ", " + values[5] + " " + values[3] + " UTC"), date = new Date(parsed_date), relative_to = new Date(), r = '', delta = parseInt(

Swift iOS doesRelativeDateFormatting have different values besides “Today” and “Yesterday”?

强颜欢笑 提交于 2019-12-04 16:33:56
问题 I have a number of dates that I am trying to represent using a relative date such as "Today, Yesterday, 1 week ago, 1 month ago" etc... This is the Swift code I am using: let dateFormatter = NSDateFormatter() dateFormatter.dateStyle = .MediumStyle dateFormatter.doesRelativeDateFormatting = true let uploadDate = dateFormatter.stringFromDate(date) Only "Today" and "Yesterday" are represented and the rest of the dates appear like the below: Nov 24, 2014 Nov 17, 2014 etc... Is there another way

NSDateFormatter relative date formatting with custom format

元气小坏坏 提交于 2019-12-04 02:22:29
So my intention is to put out dates that would look like the following: Today, August 28 Tomorrow, August 29 Friday, August 30 ...etc The issue is that it seems I can only get so close. When I setDoesRelativeDateFormatting:YES and setDateStyle to Full and setTimeStyle to None , it yields results like this: Today Tomorrow Friday, August 30, 2013 This yields the year and does not yield month and date for today and tomorrow. The other code I've tried is this: [NSDateFormatter dateFormatFromTemplate:@"eeeedMMM" options:0 locale:[NSLocale currentLocale]]; and that yields the following: Wednesday,

Force Android DateUtils.getRelativeDateTimeString() to ignore the device locale?

独自空忆成欢 提交于 2019-12-04 00:27:41
I've found using the android.text.format.DateUtils relative APIs that return values like "yesterday" or "2 hours ago" very nice - but my app does not support every language Android does. So, I default to English, but for every language I don't support, the relative string shows in the device's setting. For example, like: Last attempt: hace 11 minutos. I'd like to make the API call default to English for any languages I don't support. However, I don't see anywhere to set the Locale for the API call - I'm hoping I'm just missing it somewhere. Is there a way to set the Locale just for the API