There are 2 operations that we might play with the date/time type in
postgres:
1. Input a Date/Time: Postgres fully supports iso-8601 for Date/Time input and other formats. We can specify timezone directly in the inputs, for
example: "2008-06-25 15:30:40+08", "Jun 25 14:30:40 2008 ICT".
2. Store/Retrieve a Date/Time:
- If the date/time type is "with time zone", the internally stored value is always in UTC with GMT coordinates. An input value that has an explicit time zone specified is converted to UTC using the appropriate offset for that time zone. If no time zone is stated in the input string, then it is assumed to be in the time zone indicated by the system's timezone parameter, and is converted to UTC using the offset for the timezone zone.
- When a date/time *with time zone* value is retrieved, it is always converted from UTC to the current timezone zone, and displayed as local time in that zone. To display in another timezone, we have to specify "AT which TIME ZONE".
- When a date/time *without time zone* value is retrieved, if we specify "AT which TIME ZONE", postgres will treat the original stored date/time value in local timezone, then calculate the different between local timezone with the specified timezone and the date/time output is in that specified timezone.
Note: local timezone, server timezone or system timezone are one.
Additional links:
1. http://www.postgresql.org/docs/8.0/static/datatype-datetime.html
2. http://www.postgresql.org/docs/8.0/interactive/functions-datetime.html
3. http://www.timegenie.com/timezones.php
Wednesday, June 25, 2008
Date/Time in Postgres
Posted by
instcode
at
3:58 PM
0
comments
Saturday, January 12, 2008
Readmore...
Read more
The new format will automatically be applied to all of your posts, without having to change anything else.
Posted by
instcode
at
2:17 AM
0
comments
Saturday, December 22, 2007
Sunday, January 07, 2007
Having problem with serial communication
Read more!
instcode@hell:~$ cat /var/log/dmesg | grep tty
[17179571.132000] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[17179571.136000] 00:0a: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
instcode@hell:~$ setserial -g /dev/ttyS[01]
/dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4
instcode@hell:~$ cat /proc/tty/drivers
/dev/tty /dev/tty 5 0 system:/dev/tty
/dev/console /dev/console 5 1 system:console
/dev/ptmx /dev/ptmx 5 2 system
/dev/vc/0 /dev/vc/0 4 0 system:vtmaster
rfcomm /dev/rfcomm 216 0-255 serial
serial /dev/ttyS 4 64-111 serial
pty_slave /dev/pts 136 0-1048575 pty:slave
pty_master /dev/ptm 128 0-1048575 pty:master
pty_slave /dev/ttyp 3 0-255 pty:slave
pty_master /dev/pty 2 0-255 pty:master
unknown /dev/tty 4 1-63 console
instcode@hell:~$ stty -a
speed 38400 baud; rows 53; columns 157; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
instcode@hell:~$ ls -la /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 2007-01-05 23:53 /dev/ttyS0
instcode@hell:~$ ls -la /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 2007-01-05 23:53 /dev/ttyS0
instcode@hell:~$ groups
instcode adm dialout cdrom floppy audio dip video plugdev lpadmin scanner admin
Hix, there's no strange thing, isn't it? I have only one serial port, the ttyS0, it's also mapped to a right place in memory map, I also have permission to read/write on that device... But why it doesn't work, even I just sending some bytes through serial line:
instcode@hell:~$ echo Hello, world > /dev/ttyS0Another stupid thing is this serial port works well with Hyper-Terminal of Windows OS. Hix, again, I played with Google, and this time, after reconfigure my serial line, it worked!
Configure serial devices:Yeah, I'd forgot to enable the handshaking so that my serial cannot communicate with another one through null-modem communication.
instcode@hell:~$ sudo /bin/setserial /dev/ttyS0 baud_base 115200 auto_irq skip_test autoconfig
Enable RTS/CTS handshaking:
instcode@hell:~$ sudo stty crtscts -F /dev/ttyS0
Now everything is ok, just patching the ssh daemon of openssh to support ssh through serial line, and it'll be done. It must be an interesting work!! Hehe...
Posted by
instcode
at
10:32 AM
0
comments
Thursday, January 04, 2007
Linux - Ubuntu
It's been about 4 months since I decided to use Linux as *exclusive OS*.. Yeah, no Windows, no dual-booting, no virtual machines... And it's time to review what my thoughts about Linux :">.
Yeah, I'm sorry to tell you, Linux is an OS that's not suitable for noob :))
I'd used Linux several times before, not really from 4 months ago. Hix, I have to use it for doing my Uni's assignments. I still can remember what I lived with: a computer with only 800x600x16x60 screen (it doesn't support my VGA), no Starcraft, no music, nothing... Then everything went worse when I tried to increase the resolution: X Window fails...
All the things I got is just a solid black screen called "console"... Huhu, what I dealt with that circumstance is switching back Windows :p... Of course, this doesn't settle an end dot of using Linux, I myself still want to be "pro" in Linux, thus I tried to setup coLinux (http://www.colinux.org) in order to boot/use my Linux partition directly in Windows (I didn't use VMWare because of memory need). During that time, I learned how to setup & use VNC, X-Window server, KDevelop, Qt Designer... Yes, everything on Linux worked smoothly as well as my Windows plodded steadily :(.. I don't remember exactly, but I got rid of Linux not longer than 1 month after that :)).
Hehehe, back to now, what can I say about using Linux? Confidently talk: "dirty easy" :))... I think I can do it well on my own (of course, with my friend, Google :">).. Now I understand what called "boot loader", "kernel", "root file system", "device", "module"... Many thanks to "Building Embedded Linux" & "Primer of Embedded Linux" :">... Eehh, wait, don't shout at me :))... well, well, well... I've known, I'm just an amateur, my knowledge and skills are not enough, but I'm still learning more.
Currently, I'm using Ubuntu 6.10 Edgy Eft, my FC5's just been gone :p... Choosing & switching among distros is not hard for an amateur anymore, isn't it? :)), everything is the same, "ghẻ vẫn hoàn ghẻ" :))... Indeed, the distros, they're not important for my working, all I need is an environment with shell & common commands (yeah, I'm not afraid of solid black screen anymore, even I prefer console to GUI - an affected footprint by bro. Tha`nh lo^ng vi.t)... but what wrong with a distro that fully supports my hardwares likes Ubuntu?... Nothing! And it's reason why I'm using Ubuntu now.
E'c, I must go now.
Posted by
instcode
at
12:06 AM
0
comments
Friday, February 10, 2006
On The Web Blog
On The Web Blog:
SWT, JFace, and RCP
Java
I've been playing around with SWT (Standard Widget Toolkit) lately. And it looks very interesting. It allows creating a Java app with the look and feel and responsiveness of a native app. If you use a Java SWT application on Windows, it operates just like any other Windows app. The main example is the Eclipse platform itself.
SWT has a bunch of widgets and creating a simple app is not too bad. But, to make development a bit easier, there is JFace, which is a set of SWT helper classes.
Eclipse has the Visual Editor plug-in that allows visual editing of apps. But, I've found it to be quite quirky. It's certainly no comparison with something like Visual Studio, but when it works, it's not too bad. The widgets properties editor is convenient. But, I find myself mostly just running the app to find out what it'll look like.
And to make app development even more powerful, there is RCP (Rich Client Platform). This sits on top of SWT/JFace and makes it easy to create Eclipse plug-ins or full-blown Java apps. As a matter of fact, Eclipse was refactored in version 3.0 to be a RCP program.
General:
SWT - Answers.com
SWT - Eclipse
SWT/JFace API
Tutorials:
SWT Creates Fast, Native-looking GUIs for Your Java Apps
SWT Programming with Eclipse/a>
Use SWT for data entry
Understanding SWT Layouts
Getting Started with Eclipse and the SWT
List of more tutorials
SWT/JFace Examples:
Java2s
Visual Editor:
Visual Editor Project
VE FAQ
Build GUIs with the Eclipse Visual Editor project
Eclipse Wiki
Forums:
EclipsePluginCentral
EclipseZone
RCP:
RCP home
RCP Tutorial
SWT and JWS:
Using Java Web Start with SWT
Deploy an SWT application using Java Web Start
RCP and JWS:
Eclipse Webstart Deployment
Support launching from JWS (JNLP)
WebRCP
SWT Editors:
Visual Editor
Jigloo
SWT Designer
V4All
Applications written with RCP:
RCP Applications
OpenTime
Kadosu
Jmoney
NomadPIM
PojoeditorRCP
zdt
SWT Libraries:
TWIST
Posted by
instcode
at
12:33 AM
3
comments
Sunday, January 22, 2006
Have you started the JMapEditor project yet??
It's started... on progress ;-)...
Read more!
Posted by
instcode
at
1:12 AM
0
comments