Skip to content

Commit

Permalink
chore: use seconds timestamp system
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Dec 19, 2024
1 parent 4cd0e63 commit b81b008
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/src/browser/extensions/engines/OAIEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export abstract class OAIEngine extends AIEngine {
return
}

const timestamp = Date.now()
const timestamp = Date.now() / 1000
const message: ThreadMessage = {
id: ulid(),
thread_id: data.threadId,
Expand Down
2 changes: 1 addition & 1 deletion extensions/assistant-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class JanAssistantExtension extends AssistantExtension {
thread_location: undefined,
id: 'jan',
object: 'assistant',
created_at: Date.now(),
created_at: Date.now() / 1000,
name: 'Jan',
description: 'A default assistant that can use all downloaded models',
model: '*',
Expand Down
3 changes: 2 additions & 1 deletion web/screens/Thread/ThreadCenterPanel/TextMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ const MessageContainer: React.FC<
: (activeAssistant?.assistant_name ?? props.role)}
</div>
<p className="text-xs font-medium text-gray-400">
{props.created_at && displayDate(props.created_at ?? new Date())}
{props.created_at &&
displayDate(props.created_at ?? Date.now() / 1000)}
</p>
</div>

Expand Down
5 changes: 4 additions & 1 deletion web/utils/datetime.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export const isToday = (timestamp: number) => {
const today = new Date()
return today.setHours(0, 0, 0, 0) === new Date(timestamp).setHours(0, 0, 0, 0)
return (
today.setHours(0, 0, 0, 0) ===
new Date(timestamp * 1000).setHours(0, 0, 0, 0)
)
}

export const displayDate = (timestamp?: string | number | Date) => {
Expand Down
2 changes: 1 addition & 1 deletion web/utils/messageRequestBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ulid } from 'ulidx'

import { Stack } from '@/utils/Stack'

import { FileInfo, FileType } from '@/types/file'
import { FileInfo } from '@/types/file'

export class MessageRequestBuilder {
msgId: string
Expand Down
2 changes: 1 addition & 1 deletion web/utils/threadMessageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ThreadMessageBuilder {
}

build(): ThreadMessage {
const timestamp = Date.now()
const timestamp = Date.now() / 1000
return {
id: this.messageRequest.msgId,
thread_id: this.messageRequest.thread.id,
Expand Down

0 comments on commit b81b008

Please sign in to comment.