Skip to content

Commit

Permalink
feat(import): ✨ tz
Browse files Browse the repository at this point in the history
Support tz. Documentation.
  • Loading branch information
srl295 committed Feb 2, 2022
1 parent a3fb3b7 commit a0fcb6c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ This tag will be removed from the notes, because it is implied by the jobcode.

This will cause an entry tagged 'mytag,othertag' to have the note 'Do Some Stuff'.

- `goosebay --set 'tz=America/New_York'

Set the time zone for all entries. Defaults to UTC.

## Running

### Importing
Expand Down
6 changes: 4 additions & 2 deletions lib/goosebay.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
const { users, jobcodes, timesheets } = require('tsheets-sdk');
const DRY_RUN = false;
const { env } = require('process');
const moment = require('moment-timezone');
const tw_to_iso = require('./tw_to_iso');
class GooseBay {
constructor(config) {
Expand Down Expand Up @@ -61,6 +62,7 @@ class GooseBay {

async import(data) {
this.uid = this.config.get('uid');
this.tz = this.config.get('tz') || 'Etc/UTC';
const p = [];
for (const n of data) {
// console.dir(n);
Expand All @@ -78,8 +80,8 @@ class GooseBay {
user_id: this.uid,
jobcode_id: jobcode,
type: 'regular',
start: tw_to_iso(start),
end: tw_to_iso(end),
start: moment(tw_to_iso(start)).tz(this.tz).format(),
end: moment(tw_to_iso(end)).tz(this.tz).format(),
notes
});
}
Expand Down
33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"chalk": "^5.0.0",
"conf": "^10.1.1",
"minimist": "^1.2.5",
"moment-timezone": "^0.5.34",
"tsheets-sdk": "^1.0.0"
},
"devDependencies": {
Expand Down

0 comments on commit a0fcb6c

Please sign in to comment.