Date Formatting and Manipulation in PebbleJS

I am writing an application using PebbleJS in CloudPebble and would like to have functionality similar to that provided by Moment.js and xdate.js . In particular, I'm interested in:

  • converting date and time to string using custom format string
  • adding and subtracting days / weeks / months / years from the current time and time

These modules claim to support CommonJS, so I tried adding the files to CloudPebble and importing with something like var Moment = require('moment');

. When I do this, the app just won't work. I'm not even sure if it compiles.

All I can find in the logs is:

[PHONE] pebble-app.js:?: [PHONESIM] [WARNING] Exception decoding QemuInboundPacket.footer



source to share

1 answer

I can see here that moment.js is included in the vendor's Pebble.JS folder. The explanation for this error should be something universal, as I get the same error when I try to do the same in a new Pebble.JS HelloWorld project on CloudPebble.

I looked at the source code from pbw export from cloudpebble and it has complete library inside file. Part of the file seems to clock.js


Have a look here on how to reference the clock library and inherit the moment.js library at the same time.



All Articles