From fd4009ae73313bbe49a14ca4fe97b9e9253535ae Mon Sep 17 00:00:00 2001 From: lauzonhomeschool <85599144+lauzonhomeschool@users.noreply.github.com> Date: Sun, 9 Jun 2024 00:19:05 -0400 Subject: [PATCH] [datetime_picker] convert to pure library, improve Readme with control details and sample code --- apps/alarm/app.js | 1 - apps/datetime_picker/README.md | 29 ++++++++++++++++++++++++++- apps/datetime_picker/metadata.json | 7 ++++--- apps/datetime_picker/screenshot2.png | Bin 0 -> 3967 bytes 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 apps/datetime_picker/screenshot2.png diff --git a/apps/alarm/app.js b/apps/alarm/app.js index 64f233c5c..053505187 100644 --- a/apps/alarm/app.js +++ b/apps/alarm/app.js @@ -123,7 +123,6 @@ function showNewMenu(group) { } function showEditAlarmMenu(selectedAlarm, alarmIndex, withDate, scroll, group) { - console.log(scroll); var isNew = alarmIndex === undefined; var alarm = require("sched").newDefaultAlarm(); diff --git a/apps/datetime_picker/README.md b/apps/datetime_picker/README.md index 8dac1dceb..f602d44e1 100644 --- a/apps/datetime_picker/README.md +++ b/apps/datetime_picker/README.md @@ -1,9 +1,36 @@ # App Name -Datetime Picker allows to swipe along the bars to select date and time elements, e.g. for the datetime of Events in the Alarm App. As a standalone app, it allows to see the weekday of a given date and, once a datetime is selected, the number of days and time between that datetime and now. +Datetime Picker allows to swipe along the bars to select date and time elements, e.g. for the datetime of Events in the Alarm App. Screenshot: ![datetime with swipe controls](screenshot.png) ## Controls Swipe to increase or decrease date and time elements. Press button or go back to select shown datetime. + +![datetime with numbered swipe controls](screenshot2.png) + +1. Year: swipe up to increase, down to decrease +2. Month: swipe right to increase, left to decrease +3. Day: swipe up to increase, down to decrease +4. Week: swipe up to increase week (same day next week), down to decrease (same day previous week) +5. Weekday: swipe right to increase, left to decrease (basically the same effect as 3, but with a focus on the weekday) +6. Hour: swipe right to increase, left to decrease +7. Minutes: swipe right to increase, left to decrease +8. 15 minutes: 00, 15, 30 or 45 minutes; swipe up to increase, down to decrease; wrap-around i.e. goes back to 00 after increasing from 45 + +## How to use it in code + +Sample code which would show a prompt with the number of days and hours between now and the selected datetime: + + require("datetimeinput").input().then(result => { + E.showPrompt(`${result}\n\n${require("time_utils").formatDuration(Math.abs(result-Date.now()))}`, {buttons:{"Ok":true}}).then(function() { + load(); + }); + }); + +To set the initial value, pass a Date object named _datetime_, e.g. for today at 9:30 : + + var datetime = new Date(); + datetime.setHours(9, 30); + require("datetimeinput").input({datetime}).then(... \ No newline at end of file diff --git a/apps/datetime_picker/metadata.json b/apps/datetime_picker/metadata.json index df968589e..63ca7aa17 100644 --- a/apps/datetime_picker/metadata.json +++ b/apps/datetime_picker/metadata.json @@ -2,15 +2,16 @@ "name": "Datetime picker", "shortName":"Datetime picker", "version":"0.01", - "description": "Allows to pick a date and time by swiping.", + "description": "A library that allows to pick a date and time by swiping.", "icon":"app.png", + "type":"datetimeinput", "tags":"datetimeinput", - "supports" : ["BANGLEJS2"], + "supports" : ["BANGLEJS2"], + "provides_modules" : ["datetimeinput"], "readme": "README.md", "screenshots" : [ { "url":"screenshot.png" } ], "storage": [ {"name":"datetimeinput","url":"lib.js"}, - {"name":"datetime_picker.app.js","url":"app.js"}, {"name":"datetime_picker.img","url":"app-icon.js","evaluate":true} ] } diff --git a/apps/datetime_picker/screenshot2.png b/apps/datetime_picker/screenshot2.png new file mode 100644 index 0000000000000000000000000000000000000000..9a1f9d0485d19e107a5f70f2b9572e2186a83a85 GIT binary patch literal 3967 zcmaJ^c|4R`A0LTsgi**ASMG?6H6v?Xk~MpcvCk-B#y+|YV~fk^X1P=-B8EW?h755r zV^3q>(`2$GO^obhd7paU_rLe^{&Ak?obUOa-*cAV@B4kueLEX70X|7S5C|k-VQ%68 zyeU7*FTB9BvTn`;cpddIvNi&Ns?zxPP&`2Uc(A!M76dvO_M>o3-Im1x;K{J7h%m>X z+hKQ6q23^~P;c)*tZz`5$BkcrAwt|1CPvqB9!t**U;fr5k-&)=unqov?K1t|NnPw& zgq?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