0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-25 02:49:32 +01:00
posthog/hogvm/__tests__/dateFormat.hog

49 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

2024-07-15 14:24:23 +02:00
let dt := fromUnixTimestamp(1234377543.123456)
print(formatDateTime(dt, '%Y-%m-%d %H:%i:%S'))
print(formatDateTime(dt, '%Y-%m-%d %H:%i:%S', 'Europe/Brussels'))
print(formatDateTime(dt, '%Y-%m-%d %H:%i:%S', 'America/New_York'))
print(formatDateTime(dt, '%Y%m%dT%H%i%sZ'))
2024-07-15 14:24:23 +02:00
print('-----')
print('%a: ' || formatDateTime(dt, '%a'))
print('%b: ' || formatDateTime(dt, '%b'))
print('%c: ' || formatDateTime(dt, '%c'))
print('%C: ' || formatDateTime(dt, '%C'))
print('%d: ' || formatDateTime(dt, '%d'))
print('%D: ' || formatDateTime(dt, '%D'))
print('%e: ' || formatDateTime(dt, '%e'))
// print('%f: ' || formatDateTime(dt, '%f')) // 3 digits in Python, 6 digits in TypeScript
print('%F: ' || formatDateTime(dt, '%F'))
print('%g: ' || formatDateTime(dt, '%g'))
print('%G: ' || formatDateTime(dt, '%G'))
print('%h: ' || formatDateTime(dt, '%h'))
print('%H: ' || formatDateTime(dt, '%H'))
print('%i: ' || formatDateTime(dt, '%i'))
print('%I: ' || formatDateTime(dt, '%I'))
print('%j: ' || formatDateTime(dt, '%j'))
print('%k: ' || formatDateTime(dt, '%k'))
print('%l: ' || formatDateTime(dt, '%l'))
print('%m: ' || formatDateTime(dt, '%m'))
print('%M: ' || formatDateTime(dt, '%M'))
print('%n: ' || formatDateTime(dt, '%n'))
print('%p: ' || formatDateTime(dt, '%p'))
// print('%Q: ' || formatDateTime(dt, '%Q')) // not supported in Python
print('%r: ' || formatDateTime(dt, '%r'))
print('%R: ' || formatDateTime(dt, '%R'))
print('%s: ' || formatDateTime(dt, '%s'))
print('%S: ' || formatDateTime(dt, '%S'))
print('%t: ' || formatDateTime(dt, '%t'))
print('%T: ' || formatDateTime(dt, '%T'))
print('%u: ' || formatDateTime(dt, '%u'))
print('%V: ' || formatDateTime(dt, '%V'))
print('%w: ' || formatDateTime(dt, '%w'))
print('%W: ' || formatDateTime(dt, '%W'))
print('%y: ' || formatDateTime(dt, '%y'))
print('%Y: ' || formatDateTime(dt, '%Y'))
print('%z: ' || formatDateTime(dt, '%z'))
print('%%: ' || formatDateTime(dt, '%%'))
print('-----')
print(formatDateTime(dt, 'one banana'))
print(formatDateTime(dt, '%Y no way %m is this %d a %H real %i time %S'))