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

A presentation at jsDay 2017 in May 2017 in Verona, VR, Italy 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

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

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

Slide 6

Slide 6

Slide 7

Slide 7

Step 1 – implementation

Slide 8

Slide 8

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 9

Slide 9

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 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 31 May 2017 mm-dd-yyyy Fro m mm-dd-yyyy To Price $ Save

Slide 12

Slide 12

Slide 13

Slide 13

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 14

Slide 14

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 15

Slide 15

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 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 ??-??-?? ??-??-?? moment . localeData ()._longDateFormat[ 'L' ]; // 'MM/DD/YYYY'

Slide 17

Slide 17

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 18

Slide 18

Step 2 – testing

Slide 19

Slide 19

RTL

Slide 20

Slide 20

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 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 4 30 31 1 2 3 May 2017 dd-mm-yyyy Fro m dd-mm-yyyy To Price € Save

Slide 24

Slide 24

Step 2 – testing

Slide 25

Slide 25

“ ❤ 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 26

Slide 26

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

Slide 27

Slide 27

“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 28

Slide 28

Step 3 – Bug fixing

Slide 29

Slide 29

“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 30

Slide 30

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

Slide 31

Slide 31

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 32

Slide 32

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 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

var dateDelimiterRegEx = /[-/ ]/;

Slide 41

Slide 41

var dateDelimiterRegEx = /[-/. ]/;

Slide 42

Slide 42

var dateDelimiterRegEx = /\W /;

Slide 43

Slide 43

Sloven č ina

Slide 44

Slide 44

Slide 45

Slide 45

Slide 46

Slide 46

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

Slide 47

Slide 47

“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 48

Slide 48

Mo Tu We Th Fr Sa Su

Slide 49

Slide 49

Mo Tu We Th Fr Sa Su

Slide 50

Slide 50

Slide 51

Slide 51

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

Slide 52

Slide 52

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

Slide 53

Slide 53

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

Slide 54

Slide 54

“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 55

Slide 55

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 56

Slide 56

“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 57

Slide 57

23

Slide 58

Slide 58

Slide 59

Slide 59

“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 60

Slide 60

23 € 125

Slide 61

Slide 61

23 Rp 1,813, 351

Slide 62

Slide 62

Conclusion

Slide 63

Slide 63

Do not make any assumptions

Slide 64

Slide 64

Localization is not just about date & time

Slide 65

Slide 65

Ask users for feedback

Slide 66

Slide 66

Save relevant data

Slide 67

Slide 67

Bugs will be there

Slide 68

Slide 68

Bugfixing =

Slide 69

Slide 69

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

Slide 70

Slide 70

Questions?