How would you interpret these dates?

I need to interpret a relative date string, for example:

  • last Friday
  • this tuesday
  • next Wednesday

The "Last Friday" form is simple (take the last Friday, which is not today), but what about "this" versus "next"? Could "this Wednesday" be yesterday Thursday? Can "this" and "next" Friday be the same day in some cases and weeks separately in others?


ps Given that my target audience is American, I'm primarily interested in using English in the United States in English and a little less interested in other non-American (e.g. en-gb) customs, so if you are not American, please tell me where you are from.


My modern thinking:

  • Last X : last X not included today.
  • This X : the next next X, not including today.
  • Next X : X next week (with the beginning of the week will be a bit arbitrary).

Try it here (be sure to check if relative is allowed)

+3
source share
14 answers

, "this" . , " " . , , " " "" - , - - " " , , .

" " , . , " " , , - , , "". . . .

+1

, :

  • " " , .

  • " next " .

+7

, , ... : " X, " ", , . " X? " " .

+4

=
= *.

- . , . , . .

, . " " " ". , ( , , ).

, , - . , , , . .

. , , , . "" , , (, ) . , .

+4

, , , , . , , .

( , ) .

, , , :

.
.

, , :

( ).
8 ( ).

, , :


.

+3

, , "", "" .

, " ". . " ".

, " " " "??

, - , .

+3

Perl Date::Manip, , ; -)

#!/usr/bin/perl

use strict;
use warnings;

use Date::Manip;

my @dates = (
    'today',
    'Tuesday',
    'this Tuesday',
    'next Tuesday',
    'previous Tuesday',
    'Friday',
    'this Friday',
    'first Tuesday of August 2009',
    'first Monday of 1900',
);

print for map {
    my $date = UnixDate($_, "%A, %B %d, %Y");
    sprintf( "%-30s : %-30s\n", $_, $date || 'stumped' );
} @dates;

:

C:\Temp> d
today                          : Wednesday, August 12, 2009
Tuesday                        : Tuesday, August 11, 2009
this Tuesday                   : stumped
next Tuesday                   : Tuesday, August 18, 2009
previous Tuesday               : Tuesday, August 11, 2009
Friday                         : Friday, August 14, 2009
this Friday                    : stumped
first Tuesday of August 2009   : Tuesday, August 04, 2009
first Monday of 1900           : Monday, January 01, 1900
+2

" " , . , " " .

" ", , , .

+1

" ", ", " / " ". ( ) . , . , . - , , , 8 .

, , .

+1

:

, , , . , "" , ; , .

" " " ".

+1

:
: .
: .
: .
: . .

, Next, . , .

:
:
:

:
:
: .

:
: 2
: .

:
: ( , 2-3)
: .

+1

"this" "next". , , .

:

  • .
  • .
  • , - .
  • , .

- (, " ", " " ..).

+1

- , , - 1 .

, " " .

0

, , , , , ( , ), , , . , , , , , . , , , , , abd .

0

Source: https://habr.com/ru/post/1715001/


All Articles