Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyone found a way to handle Dates in Ionic production build? #36

Open
dave-ok opened this issue Jun 6, 2019 · 5 comments
Open

Anyone found a way to handle Dates in Ionic production build? #36

dave-ok opened this issue Jun 6, 2019 · 5 comments

Comments

@dave-ok
Copy link

dave-ok commented Jun 6, 2019

Please has anyone found a way around the date datatype problem with ionic production builds. I am building an app which is date-centric and this limitation is a downer cos typeorm has everything I need but this. Please help! I need pointers or suggestions

@AchevezAim
Copy link

Is handling date as unix time an option?

@dave-ok
Copy link
Author

dave-ok commented Jul 15, 2019

Is handling date as unix time an option?

Pls I dont understand. Can you elaborate?

My question was based on the limitations listed for Ionic production builds where date types are seen as objects and eventually converted to object columns instead of date columns

#3 (comment)

@AchevezAim
Copy link

Well, I handle dates as unix time (milliseconds since epoch).

Let's say you have:

export class Thing {
  @PrimaryColumn({ unique: true })
  id: number;
  date: number;
}

When you fetch it, you will get date as number type, you can then use new Date(date*1000)

Or you can make a getter that returns a date object:

export class Thing {
  @PrimaryColumn({ unique: true })
  id: number;
  date: number;

 getDate(): Date{
  return new Date(this.date*1000);
 }
}

It's just a suggestion

@dave-ok
Copy link
Author

dave-ok commented Jul 16, 2019

@AchevezAim Thanks a bunch!
Looks like this should work. Date comparison is critical to the project I am working on and with your suggestion I can do just that. I'll get right on it. And thanks again!

@Sampath-Lokuge
Copy link

@dave-ok Is that working for you? I also like to work on this ORM library and Ionic 4. But not started yet. So how's your experience with this ORM and of course Date manipulation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants