Skip to content
This repository has been archived by the owner on Nov 24, 2020. It is now read-only.

Commit

Permalink
Implement timezone in targets (#47)
Browse files Browse the repository at this point in the history
* Implement timezone in targets

* Allow timezone to be nullable
  • Loading branch information
dgadelha authored and lbguilherme committed Mar 19, 2019
1 parent 25e3901 commit 9b5d411
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/target/java_android.cr
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ END
put("width", size.x);
put("height", size.y);
}});
device.put("timezone", Calendar.getInstance().getTimeZone().getID());
SharedPreferences pref = context().getSharedPreferences("api", Context.MODE_PRIVATE);
if (pref.contains("deviceId"))
device.put("id", pref.getString("deviceId", null));
Expand Down
1 change: 1 addition & 0 deletions src/target/swift_ios.cr
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ END
}
device["language"] = Locale.preferredLanguages[0]
device["timezone"] = TimeZone.current.identifier
if let currentId = deviceId {
device["id"] = currentId
}
Expand Down
5 changes: 3 additions & 2 deletions src/target/typescript_nodeclient.cr
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@ END
language: null,
screen: null,
platform: null,
version: null
version: null,
timezone: null
};
if (this.deviceId)
device.id = this.deviceId;
return device;
}
private async makeRequest({name, args}: {name: string, args: any}) {
const deviceData = this.device();
const body = {
Expand Down
1 change: 1 addition & 0 deletions src/target/typescript_nodeserver.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface DBDevice {
language: string
lastActiveAt?: Date
push?: string
timezone?: string | null
}
interface DBApiCall {
Expand Down
3 changes: 2 additions & 1 deletion src/target/typescript_web.cr
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ async function device() {
height: screen.height
},
version: me ? me.src : "",
language: navigator.language
language: navigator.language,
timezone: typeof Intl === "object" ? Intl.DateTimeFormat().resolvedOptions().timeZone : null
};
const deviceId = getDeviceId();
if (deviceId)
Expand Down

0 comments on commit 9b5d411

Please sign in to comment.