Git Product home page Git Product logo

Comments (11)

 avatar commented on July 2, 2024

@diabloevagto @oahehc 請給意見囉

from camera-trap-api.

oahehc avatar oahehc commented on July 2, 2024

如果要統一但又要涵蓋上述樣式, 應該是用 timestamp

from camera-trap-api.

 avatar commented on July 2, 2024

所以是不論前端 widget 顯示什麼,一律都用 timestamp 寫入?然後顯示時間時再從 timestamp 轉?

from camera-trap-api.

oahehc avatar oahehc commented on July 2, 2024

我的想法是這樣
看有沒有人有其他意見

from camera-trap-api.

trashmai avatar trashmai commented on July 2, 2024

目前很多不用 timestamp 的理由是保存原始輸入資訊以供複查(相機可能會設定錯誤、還有EXIF的時間格式可能有出入、時區轉換差異),再來就是減少前端多一道 render 手續,這兩塊以外用的部分我同意用 timestamp。

dailyTestTime.time 是資料檢核用的,直接用 regex 就可以確認是否為定時測試照片。不然「每天中午12時」要以 timestamp 來表達並不方便。

from camera-trap-api.

 avatar commented on July 2, 2024

前端的 render 其實可以統一以一個函式處理,函式中可設定 render 的格式,這樣未來如果要統一改成其它格式,只要改這個函式即可。

那麼:

  1. 事件的時間統一使用 timestamp
  2. 設定的時間(如 dailyTestTime.time)統一使用 ISO 8601
  3. 若是人工輸入的資料,或上傳的資料,事件的時間均加上一個 verbatim* 欄位供未來確認及除錯用

這樣可以?

from camera-trap-api.

kelp404 avatar kelp404 commented on July 2, 2024

會把 timestamp 除以 1000 的原因是什麼呢?
https://github.com/TaiBIF/camera-trap-api/blob/master/common/mixins/timeStamp.js#L11-L21

因為浮點數存進資料庫後在拿出來有可能會不一樣。
https://stackoverflow.com/questions/44693985/floating-point-numbers-do-not-match-in-aggregation

from camera-trap-api.

 avatar commented on July 2, 2024

@trashmai : 「因為 javascript 的時間是微秒。」Hope this helps?

from camera-trap-api.

kelp404 avatar kelp404 commented on July 2, 2024

以我的經驗來說我習慣存 iso8601(2018-12-03T03:23:54.275Z),如果是跨國服務來說資料庫一定是 UTC,然後在前端用 JavaScript 轉成當地時間,因為有些國家有夏時令的問題,很難在後端處理。

MongoDB 好像可以用 ISODate https://docs.mongodb.com/manual/core/shell-types/
可以存到微秒

from camera-trap-api.

 avatar commented on July 2, 2024

考慮 MongoDB 支援 ISODate,也許我們就以此格式儲存?
然後前端在準備 request JSON 時大概是用到這個 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString ?

from camera-trap-api.

 avatar commented on July 2, 2024

no longer applicable

from camera-trap-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.