Calendar / Kalender / تقويم (aka, the fun of locali[zs]ation)

A presentation at JSConfEU in May 2017 in Berlin, Germany by Jayne Mast

Slide 1

Slide 1

Calendar / Kalender / ميوقت (aka, the fun of locali[zs]ation) mìosachan kalendá ř رڊنيلئڪ календарь

í2 רַאדנעלַאק ປະຕiທiນ 'ISjaH

Slide 2

Slide 2

Paul Verbeek-Mast

Slide 3

Slide 3

Slide 4

Slide 4

Slide 5

Slide 5

Slide 6

Slide 6

Calendar / Kalender / ميوقت (aka, the fun of locali[zs]ation) mìosachan kalendá ř رڊنيلئڪ календарь

í2 רַאדנעלַאק ປະຕiທiນ 'ISjaH

Slide 7

Slide 7

Slide 8

Slide 8

Step 1 – implementation

Slide 9

Slide 9

http://infiniteundo.com/post/25326999628/falsehoods-programmers- believe-about-time http://infiniteundo.com/post/25509354022/more-falsehoods- programmers-believe-about-time F alsehoods programmers believe about time More f alsehoods programmers believe about time

Slide 10

Slide 10

Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 May 2017 dd-mm-yyyy Fro m dd-mm-yyyy To Price € Save

Slide 11

Slide 11

Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 May 2017 dd-mm-yyyy Fro m dd-mm-yyyy To Price € Save

Slide 12

Slide 12

Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 31 May 2017 mm-dd-yyyy Fro m mm-dd-yyyy To Price $ Save

Slide 13

Slide 13

Slide 14

Slide 14

May 2017 Fro m To Price $ Save moment . localeData (). firstDayOfWeek (); // 0-6 (Sunday to Saturday)

moment . localeData (). weekdaysMin (); //["Su", "Mo", "Tu", "We", "Th", "Fr", “ Sa"]

Slide 15

Slide 15

May 2017 Fro m To Price $ Save Mo Tu We Th Fr Sa Su var calMoment = moment (); calMoment. startOf ( 'month' ). startOf ( 'week' ). date (); // 31 31

Slide 16

Slide 16

May 2017 Fro m To Price $ Save Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 31 calMoment. add ( 1 , 'd' ). date (); // 2 calMoment. isSame ( moment (). endOf ( 'month' ). endOf ( 'week' ). startOf ( 'day' ));

Slide 17

Slide 17

May 2017 Fro m To Price $ Save Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 31 ??-??-?? ??-??-?? moment . localeData ()._longDateFormat[ 'L' ]; // 'MM/DD/YYYY'

Slide 18

Slide 18

Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 31 May 2017 MM/DD/YYYY Fro m MM/DD/YYYY To Price $ Save

Slide 19

Slide 19

Step 2 – testing

Slide 20

Slide 20

RTL

Slide 21

Slide 21

Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 May 2017 dd-mm-yyyy Fro m dd-mm-yyyy To Price € Save

Slide 22

Slide 22

Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 May 2017 dd-mm-yyyy Fro m dd-mm-yyyy To Price € Save

Slide 23

Slide 23

Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 May 2017 dd-mm-yyyy Fro m dd-mm-yyyy To Price € Save

Slide 24

Slide 24

Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 4 30 31 1 2 3 May 2017 dd-mm-yyyy Fro m dd-mm-yyyy To Price € Save

Slide 25

Slide 25

Step 2 – testing

Slide 26

Slide 26

“ ❤ the new interface!” “I can finally find my reservations!” “Looks a lot better, just like {popular rental website for apartments}’s calendar!” “much better overview”

Slide 27

Slide 27

“hate it, bring the old one back” “who made this " ? ”

Slide 28

Slide 28

“Reservations aren’t showing up” “the date selection is not working” “The prices aren’t showing properly” “All reservations are a day off” “Why are closed dates red?”

Slide 29

Slide 29

Step 3 – Bug fixing

Slide 30

Slide 30

“the date selection is not working” “Reservations aren’t showing up” “The prices aren’t showing properly” “All reservations are a day off” “Why are closed dates red?”

Slide 31

Slide 31

dd-mm-yyyy Fro m dd-mm-yyyy To

Slide 32

Slide 32

05/07/2017 moment.localeData()._longDateFormat['L']; MM/DD/YYYY $.datepicker.parseDate('MM/DD/YYYY', '05/07/2017'); $.datepicker.parseDate('mm/dd/yy ', '05/07/2017');

Slide 33

Slide 33

function convertToJQueryUI() { var format = moment().localeData()._longDateFormat['L']; var dateDelimiterRegEx = /[-/ ]/; var delimiter = (dateDelimiterRegEx.exec(format) || '')[0]; var dateTransform = { 'YYYY': 'yy', … 'D': 'd' }; function getTransformedDatePart(part) { return dateTransform[part] || part; } return format .split(dateDelimiterRegEx) .map(getTransformedDatePart) .join(delimiter); };

Slide 34

Slide 34

function convertToJQueryUI() { var format = moment().localeData()._longDateFormat['L']; var dateDelimiterRegEx = /[-/ ]/; var delimiter = (dateDelimiterRegEx.exec(format) || '')[0]; var dateTransform = { 'YYYY': 'yy', … 'D': 'd' }; function getTransformedDatePart(part) { return dateTransform[part] || part; } return format .split(dateDelimiterRegEx) .map(getTransformedDatePart) .join(delimiter); };

Slide 35

Slide 35

function convertToJQueryUI() { var format = moment().localeData()._longDateFormat['L']; var dateDelimiterRegEx = /[-/ ]/; var delimiter = (dateDelimiterRegEx.exec(format) || '')[0]; var dateTransform = { 'YYYY': 'yy', … 'D': 'd' }; function getTransformedDatePart(part) { return dateTransform[part] || part; } return format .split(dateDelimiterRegEx) .map(getTransformedDatePart) .join(delimiter); };

Slide 36

Slide 36

function convertToJQueryUI() { var format = moment().localeData()._longDateFormat['L'];

var dateDelimiterRegEx = /[-/]/;

var delimiter = (dateDelimiterRegEx.exec(format) || '')[0]; var dateTransform = { 'YYYY': 'yy', … 'D': 'd' }; function getTransformedDatePart(part) { return dateTransform[part] || part; } return format .split(dateDelimiterRegEx) .map(getTransformedDatePart) .join(delimiter); };

Slide 37

Slide 37

function convertToJQueryUI() { var format = moment().localeData()._longDateFormat['L'];

var dateDelimiterRegEx = /[-/]/;

var delimiter = (dateDelimiterRegEx.exec(format) || '')[0];

var dateTransform = { 
    'YYYY': 'yy', 
    … 
    'D': 'd' 
}; 
function getTransformedDatePart(part) { 
    return dateTransform[part] || part; 
} 
return format 
    .split(dateDelimiterRegEx) 
    .map(getTransformedDatePart) 
    .join(delimiter); 

};

Slide 38

Slide 38

function convertToJQueryUI() { var format = moment().localeData()._longDateFormat['L'];

var dateDelimiterRegEx = /[-/]/;

var delimiter = (dateDelimiterRegEx.exec(format) || '')[0];

var dateTransform = { 'YYYY': 'yy', … 'D': 'd' };

function getTransformedDatePart(part) { return dateTransform[part] || part; } return format .split(dateDelimiterRegEx) .map(getTransformedDatePart) .join(delimiter); };

Slide 39

Slide 39

function convertToJQueryUI() { var format = moment().localeData()._longDateFormat['L'];

var dateDelimiterRegEx = /[-/]/;

var delimiter = (dateDelimiterRegEx.exec(format) || '')[0];

var dateTransform = { 'YYYY': 'yy', … 'D': 'd' }; function getTransformedDatePart(part) { return dateTransform[part] || part; }

return format .split(dateDelimiterRegEx) .map(getTransformedDatePart) .join(delimiter); };

Slide 40

Slide 40

function convertToJQueryUI() { var format = moment().localeData()._longDateFormat['L']; var dateDelimiterRegEx = /[-/ ]/; var delimiter = (dateDelimiterRegEx.exec(format) || '')[0]; var dateTransform = { 'YYYY': 'yy', … 'D': 'd' }; function getTransformedDatePart(part) { return dateTransform[part] || part; } return format .split(dateDelimiterRegEx) .map(getTransformedDatePart) .join(delimiter); };

Slide 41

Slide 41

var dateDelimiterRegEx = /[-/ ]/;

Slide 42

Slide 42

var dateDelimiterRegEx = /[-/. ]/;

Slide 43

Slide 43

var dateDelimiterRegEx = /\W /;

Slide 44

Slide 44

Sloven č ina

Slide 45

Slide 45

Slide 46

Slide 46

Slide 47

Slide 47

DD. MM. YYYY var dateDelimiterRegEx = /\W /; var dateDelimiterRegEx = /\W+ /;

Slide 48

Slide 48

“Reservations aren’t showing up” “the date selection is not working” “The prices aren’t showing properly” “All reservations are a day off” “Why are closed dates red?”

Slide 49

Slide 49

Mo Tu We Th Fr Sa Su

Slide 50

Slide 50

Mo Tu We Th Fr Sa Su

Slide 51

Slide 51

Slide 52

Slide 52

https://en.wikipedia.org/wiki/Time_in_Brazil

Slide 53

Slide 53

dayA.startOf('day').add(1, 'd').isSame(dayB.startOf('day'))

Slide 54

Slide 54

dayA.add(1, 'd').startOf('day').isSame(dayB.startOf('day'))

Slide 55

Slide 55

“All reservations are a day off” “Reservations aren’t showing up” “the date selection is not working” “The prices aren’t showing properly” “Why are closed dates red?”

Slide 56

Slide 56

Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1 2 3 4 May 2017 dd-mm-yyyy Fro m dd-mm-yyyy To Price € Save

Slide 57

Slide 57

“Why are closed dates red?” “Reservations aren’t showing up” “the date selection is not working” “The prices aren’t showing properly” “All reservations are a day off”

Slide 58

Slide 58

23

Slide 59

Slide 59

Slide 60

Slide 60

“The prices aren’t showing properly” “Reservations aren’t showing up” “the date selection is not working” “All reservations are a day off” “Why are closed dates red?”

Slide 61

Slide 61

23 € 125

Slide 62

Slide 62

23 Rp 1,813, 351

Slide 63

Slide 63

Conclusion

Slide 64

Slide 64

Do not make any assumptions

Slide 65

Slide 65

Localization is not just about date & time

Slide 66

Slide 66

Ask users for feedback

Slide 67

Slide 67

Save relevant data

Slide 68

Slide 68

Bugs will be there

Slide 69

Slide 69

Bugfixing =

Slide 70

Slide 70

@_paulverbeek @fronteersconf paul.verbeek@spronq .com 705649555

Slide 71

Slide 71

Questions?