It is currently Fri Sep 10, 2010 3:30 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Extended FormatDate
PostPosted: Sat Dec 04, 2004 9:43 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed May 28, 2003 6:57 am
Posts: 173
Location: Munich
Code:
; --------------------------------------------
; Format PB Date (no time) thru Win API  (ASM)
; with localized day and month names (opt)
; --------------------------------------------
; Tokens in mask$  (case sensitive!)
; yyyy   yy    Year (4/2 digits)
; MM     M     Month, numeric (with/without leading zero)
; MMMM   MMM   Month by name (long/short)
; dd     d     Day (with/without leading zero)
; dddd   ddd   Day of week (long/short)

#DateBaseHigh = 27111902
#DateBaseLow = -717324288

Procedure.s FormatDateX(mask$,date_)
  ft_.FILETIME : fs_.SYSTEMTIME
  MOV Eax,date_
  MOV Ebx,10000000
  MUL Ebx
  ADD Eax,#DateBaseLow
  ADC Edx,#DateBaseHigh
  MOV ft_\dwLowDateTime,Eax
  MOV ft_\dwHighDateTime,Edx
  FileTimeToSystemTime_(ft_,fs_)
  buf.s = Space(64)
  GetDateFormat_(#LOCALE_USER_DEFAULT,0,td,mask$,buf,64)
ProcedureReturn buf
EndProcedure

; test
Debug FormatDateX("dddd, d.MMMM yyyy",Date())
Debug FormatDateX("M/d/yyyy",Date())

[edit] I was playing with conversions. Of course this also works:
Code:
Procedure.s FormatDateX(mask$,date_)
  fs_.SYSTEMTIME
  fs_\wYear = Year(date_)
  fs_\wMonth = Month(date_)
  fs_\wDay = Day(date_)
  fs_\wDayOfWeek = DayOfWeek(date_)
  buf.s = Space(64)
  GetDateFormat_(#LOCALE_USER_DEFAULT,0,td,mask$,buf,64)
ProcedureReturn buf
EndProcedure

_________________
Horst.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye